@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,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from "
|
|
1
|
+
import type {
|
|
2
|
+
Abi,
|
|
3
|
+
Address,
|
|
4
|
+
Chain,
|
|
5
|
+
Client,
|
|
6
|
+
ContractFunctionArgs,
|
|
7
|
+
ContractFunctionName,
|
|
8
|
+
Hash,
|
|
9
|
+
Prettify,
|
|
10
|
+
Transport,
|
|
11
|
+
TypedData,
|
|
12
|
+
WriteContractParameters
|
|
13
|
+
} from "viem"
|
|
14
|
+
import type { EntryPointVersion, SmartAccount } from "viem/account-abstraction"
|
|
15
|
+
import { getKernelV3ModuleCurrentNonce } from "../../actions/account-client/getKernelV3ModuleCurrentNonce.js"
|
|
15
16
|
import {
|
|
16
17
|
type GetUserOperationGasPriceReturnType,
|
|
17
18
|
getUserOperationGasPrice
|
|
@@ -20,18 +21,18 @@ import {
|
|
|
20
21
|
type InvalidateNonceParameters,
|
|
21
22
|
invalidateNonce
|
|
22
23
|
} from "../../actions/account-client/invalidateNonce.js"
|
|
24
|
+
import { sendTransaction } from "../../actions/account-client/sendTransaction.js"
|
|
25
|
+
import { signMessage } from "../../actions/account-client/signMessage.js"
|
|
26
|
+
import { signTypedData } from "../../actions/account-client/signTypedData.js"
|
|
27
|
+
import { writeContract } from "../../actions/account-client/writeContract.js"
|
|
23
28
|
import type {
|
|
24
29
|
ChangeSudoValidatorParameters,
|
|
25
|
-
SignUserOperationParameters,
|
|
26
30
|
SignUserOperationReturnType,
|
|
27
|
-
SponsorUserOperationEip7677Parameters,
|
|
28
|
-
SponsorUserOperationEip7677ReturnType,
|
|
29
31
|
UninstallPluginParameters
|
|
30
32
|
} from "../../actions/index.js"
|
|
31
33
|
import {
|
|
32
34
|
changeSudoValidator,
|
|
33
35
|
signUserOperation,
|
|
34
|
-
sponsorUserOperationEip7677,
|
|
35
36
|
uninstallPlugin
|
|
36
37
|
} from "../../actions/index.js"
|
|
37
38
|
import {
|
|
@@ -46,80 +47,69 @@ import {
|
|
|
46
47
|
} from "../../actions/paymaster/sponsorUserOperation.js"
|
|
47
48
|
import type { ZeroDevPaymasterClient } from "../paymasterClient.js"
|
|
48
49
|
|
|
49
|
-
export type ZeroDevPaymasterClientActions<
|
|
50
|
+
export type ZeroDevPaymasterClientActions<
|
|
51
|
+
entryPointVersion extends EntryPointVersion
|
|
52
|
+
> = {
|
|
50
53
|
/**
|
|
51
54
|
* Returns paymasterAndData & updated gas parameters required to sponsor a userOperation.
|
|
52
55
|
*/
|
|
53
56
|
sponsorUserOperation: (
|
|
54
|
-
args: SponsorUserOperationParameters<
|
|
55
|
-
) => Promise<SponsorUserOperationReturnType<
|
|
57
|
+
args: SponsorUserOperationParameters<entryPointVersion>
|
|
58
|
+
) => Promise<SponsorUserOperationReturnType<entryPointVersion>>
|
|
56
59
|
estimateGasInERC20: (
|
|
57
60
|
args: EstimateGasInERC20Parameters
|
|
58
61
|
) => Promise<EstimateGasInERC20ReturnType>
|
|
59
|
-
sponsorUserOperationEip7677: (
|
|
60
|
-
args: SponsorUserOperationEip7677Parameters<entryPoint>,
|
|
61
|
-
bundlerClient: BundlerClient<entryPoint>,
|
|
62
|
-
stateOverrides?: StateOverrides
|
|
63
|
-
) => Promise<SponsorUserOperationEip7677ReturnType<entryPoint>>
|
|
64
62
|
}
|
|
65
63
|
|
|
66
64
|
export const zerodevPaymasterActions =
|
|
67
|
-
<
|
|
68
|
-
|
|
65
|
+
<entryPointVersion extends EntryPointVersion>(entryPoint: {
|
|
66
|
+
address: Address
|
|
67
|
+
version: entryPointVersion
|
|
68
|
+
}) =>
|
|
69
|
+
(client: Client): ZeroDevPaymasterClientActions<entryPointVersion> => ({
|
|
69
70
|
sponsorUserOperation: async (
|
|
70
|
-
args: Omit<
|
|
71
|
+
args: Omit<
|
|
72
|
+
SponsorUserOperationParameters<entryPointVersion>,
|
|
73
|
+
"entryPoint"
|
|
74
|
+
>
|
|
71
75
|
) =>
|
|
72
|
-
sponsorUserOperation
|
|
73
|
-
client as ZeroDevPaymasterClient<
|
|
76
|
+
sponsorUserOperation(
|
|
77
|
+
client as ZeroDevPaymasterClient<entryPointVersion>,
|
|
74
78
|
{
|
|
75
79
|
...args,
|
|
76
|
-
entryPoint
|
|
80
|
+
entryPoint
|
|
77
81
|
}
|
|
78
82
|
),
|
|
79
83
|
estimateGasInERC20: async (args: EstimateGasInERC20Parameters) =>
|
|
80
84
|
estimateGasInERC20(
|
|
81
|
-
client as ZeroDevPaymasterClient<
|
|
85
|
+
client as ZeroDevPaymasterClient<entryPointVersion>,
|
|
82
86
|
args
|
|
83
|
-
),
|
|
84
|
-
sponsorUserOperationEip7677: async (
|
|
85
|
-
args: SponsorUserOperationEip7677Parameters<entryPoint>,
|
|
86
|
-
bundlerClient: BundlerClient<entryPoint>,
|
|
87
|
-
stateOverrides?: StateOverrides
|
|
88
|
-
) =>
|
|
89
|
-
sponsorUserOperationEip7677(
|
|
90
|
-
client as ZeroDevPaymasterClient<entryPoint>,
|
|
91
|
-
args,
|
|
92
|
-
bundlerClient,
|
|
93
|
-
stateOverrides
|
|
94
87
|
)
|
|
95
88
|
})
|
|
96
89
|
|
|
97
90
|
export type KernelAccountClientActions<
|
|
98
|
-
entryPoint extends EntryPoint,
|
|
99
|
-
TTransport extends Transport = Transport,
|
|
100
91
|
TChain extends Chain | undefined = Chain | undefined,
|
|
101
|
-
TSmartAccount extends
|
|
102
|
-
|
|
103
|
-
| undefined =
|
|
104
|
-
| KernelSmartAccount<entryPoint, TTransport, TChain>
|
|
105
|
-
| undefined
|
|
106
|
-
> = SmartAccountActions<entryPoint, TTransport, TChain, TSmartAccount> & {
|
|
92
|
+
TSmartAccount extends SmartAccount | undefined = SmartAccount | undefined
|
|
93
|
+
> = {
|
|
107
94
|
/**
|
|
108
95
|
* Signs a user operation with the given transport, chain, and smart account.
|
|
109
96
|
*
|
|
110
97
|
* @param args - Parameters for the signUserOperation function
|
|
111
98
|
* @returns A promise that resolves to the result of the signUserOperation function
|
|
112
99
|
*/
|
|
113
|
-
signUserOperation: <
|
|
100
|
+
signUserOperation: <
|
|
101
|
+
accountOverride extends SmartAccount | undefined = undefined,
|
|
102
|
+
calls extends readonly unknown[] = readonly unknown[]
|
|
103
|
+
>(
|
|
114
104
|
args: Parameters<
|
|
115
105
|
typeof signUserOperation<
|
|
116
|
-
|
|
117
|
-
TTransport,
|
|
106
|
+
TSmartAccount,
|
|
118
107
|
TChain,
|
|
119
|
-
|
|
108
|
+
accountOverride,
|
|
109
|
+
calls
|
|
120
110
|
>
|
|
121
111
|
>[1]
|
|
122
|
-
) => Promise<SignUserOperationReturnType
|
|
112
|
+
) => Promise<SignUserOperationReturnType>
|
|
123
113
|
/**
|
|
124
114
|
* Returns the live gas prices that you can use to send a user operation.
|
|
125
115
|
*
|
|
@@ -136,24 +126,24 @@ export type KernelAccountClientActions<
|
|
|
136
126
|
* @param args - {@link UninstallPermissionParameters}
|
|
137
127
|
* @returns The [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) hash. {@link SendTransactionReturnType}
|
|
138
128
|
*/
|
|
139
|
-
uninstallPlugin:
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
TSmartAccount
|
|
145
|
-
>
|
|
129
|
+
uninstallPlugin: <
|
|
130
|
+
accountOverride extends SmartAccount | undefined = undefined,
|
|
131
|
+
calls extends readonly unknown[] = readonly unknown[]
|
|
132
|
+
>(
|
|
133
|
+
args: UninstallPluginParameters<TSmartAccount, accountOverride, calls>
|
|
146
134
|
) => Promise<Hash>
|
|
147
135
|
/**
|
|
148
136
|
* Creates, signs, and sends a user operation to change sudo validator to the network.
|
|
149
137
|
* This function also allows you to sponsor this transaction if sender is a smartAccount
|
|
150
138
|
*/
|
|
151
|
-
changeSudoValidator:
|
|
139
|
+
changeSudoValidator: <
|
|
140
|
+
accountOverride extends SmartAccount | undefined = undefined,
|
|
141
|
+
calls extends readonly unknown[] = readonly unknown[]
|
|
142
|
+
>(
|
|
152
143
|
args: ChangeSudoValidatorParameters<
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
TSmartAccount
|
|
144
|
+
TSmartAccount,
|
|
145
|
+
accountOverride,
|
|
146
|
+
calls
|
|
157
147
|
>
|
|
158
148
|
) => Promise<Hash>
|
|
159
149
|
|
|
@@ -166,116 +156,330 @@ export type KernelAccountClientActions<
|
|
|
166
156
|
* @returns The [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) hash. {@link SendTransactionReturnType}
|
|
167
157
|
*/
|
|
168
158
|
invalidateNonce: <
|
|
169
|
-
|
|
159
|
+
accountOverride extends SmartAccount | undefined = undefined,
|
|
160
|
+
calls extends readonly unknown[] = readonly unknown[]
|
|
170
161
|
>(
|
|
171
|
-
args: InvalidateNonceParameters<
|
|
172
|
-
entryPoint,
|
|
173
|
-
TTransport,
|
|
174
|
-
TChain,
|
|
175
|
-
TSmartAccount,
|
|
176
|
-
TChainOverride
|
|
177
|
-
>
|
|
162
|
+
args: InvalidateNonceParameters<TSmartAccount, accountOverride, calls>
|
|
178
163
|
) => Promise<Hash>
|
|
179
164
|
/**
|
|
180
165
|
* Creates, signs, and sends a transaction to fetch KernelV3 module nonce to the network.
|
|
181
166
|
* This function also allows you to sponsor this transaction if sender is a smartAccount
|
|
182
167
|
*
|
|
183
168
|
*
|
|
184
|
-
* @param args - {@link GetKernelV3ModuleCurrentNonceParameters}
|
|
185
169
|
* @returns nonce
|
|
186
170
|
*/
|
|
187
|
-
getKernelV3ModuleCurrentNonce: <
|
|
188
|
-
|
|
171
|
+
getKernelV3ModuleCurrentNonce: () => Promise<number>
|
|
172
|
+
/**
|
|
173
|
+
* Creates, signs, and sends a new transaction to the network.
|
|
174
|
+
* This function also allows you to sponsor this transaction if sender is a smartAccount
|
|
175
|
+
*
|
|
176
|
+
* - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html
|
|
177
|
+
* - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions
|
|
178
|
+
* - JSON-RPC Methods:
|
|
179
|
+
* - JSON-RPC Accounts: [`eth_sendTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendtransaction)
|
|
180
|
+
* - Local Accounts: [`eth_sendRawTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction)
|
|
181
|
+
*
|
|
182
|
+
* @param args - {@link SendTransactionParameters}
|
|
183
|
+
* @returns The [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) hash. {@link SendTransactionReturnType}
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* import { createWalletClient, custom } from 'viem'
|
|
187
|
+
* import { mainnet } from 'viem/chains'
|
|
188
|
+
*
|
|
189
|
+
* const client = createWalletClient({
|
|
190
|
+
* chain: mainnet,
|
|
191
|
+
* transport: custom(window.ethereum),
|
|
192
|
+
* })
|
|
193
|
+
* const hash = await client.sendTransaction({
|
|
194
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
195
|
+
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
196
|
+
* value: 1000000000000000000n,
|
|
197
|
+
* })
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* // Account Hoisting
|
|
201
|
+
* import { createWalletClient, http } from 'viem'
|
|
202
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
203
|
+
* import { mainnet } from 'viem/chains'
|
|
204
|
+
*
|
|
205
|
+
* const client = createWalletClient({
|
|
206
|
+
* account: privateKeyToAccount('0x…'),
|
|
207
|
+
* chain: mainnet,
|
|
208
|
+
* transport: http(),
|
|
209
|
+
* })
|
|
210
|
+
* const hash = await client.sendTransaction({
|
|
211
|
+
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
212
|
+
* value: 1000000000000000000n,
|
|
213
|
+
* })
|
|
214
|
+
*/
|
|
215
|
+
sendTransaction: <
|
|
216
|
+
TChainOverride extends Chain | undefined = undefined,
|
|
217
|
+
accountOverride extends SmartAccount | undefined = undefined,
|
|
218
|
+
calls extends readonly unknown[] = readonly unknown[]
|
|
219
|
+
>(
|
|
220
|
+
args: Parameters<
|
|
221
|
+
typeof sendTransaction<
|
|
222
|
+
TSmartAccount,
|
|
223
|
+
TChain,
|
|
224
|
+
accountOverride,
|
|
225
|
+
TChainOverride,
|
|
226
|
+
calls
|
|
227
|
+
>
|
|
228
|
+
>[1]
|
|
229
|
+
) => Promise<Hash>
|
|
230
|
+
/**
|
|
231
|
+
* Calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191): `keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))`.
|
|
232
|
+
*
|
|
233
|
+
* - Docs: https://viem.sh/docs/actions/wallet/signMessage.html
|
|
234
|
+
* - JSON-RPC Methods:
|
|
235
|
+
* - JSON-RPC Accounts: [`personal_sign`](https://docs.metamask.io/guide/signing-data.html#personal-sign)
|
|
236
|
+
* - Local Accounts: Signs locally. No JSON-RPC request.
|
|
237
|
+
*
|
|
238
|
+
* With the calculated signature, you can:
|
|
239
|
+
* - use [`verifyMessage`](https://viem.sh/docs/utilities/verifyMessage.html) to verify the signature,
|
|
240
|
+
* - use [`recoverMessageAddress`](https://viem.sh/docs/utilities/recoverMessageAddress.html) to recover the signing address from a signature.
|
|
241
|
+
*
|
|
242
|
+
* @param args - {@link SignMessageParameters}
|
|
243
|
+
* @returns The signed message. {@link SignMessageReturnType}
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* import { createWalletClient, custom } from 'viem'
|
|
247
|
+
* import { mainnet } from 'viem/chains'
|
|
248
|
+
*
|
|
249
|
+
* const client = createWalletClient({
|
|
250
|
+
* chain: mainnet,
|
|
251
|
+
* transport: custom(window.ethereum),
|
|
252
|
+
* })
|
|
253
|
+
* const signature = await client.signMessage({
|
|
254
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
255
|
+
* message: 'hello world',
|
|
256
|
+
* })
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* // Account Hoisting
|
|
260
|
+
* import { createWalletClient, http } from 'viem'
|
|
261
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
262
|
+
* import { mainnet } from 'viem/chains'
|
|
263
|
+
*
|
|
264
|
+
* const client = createWalletClient({
|
|
265
|
+
* account: privateKeyToAccount('0x…'),
|
|
266
|
+
* chain: mainnet,
|
|
267
|
+
* transport: http(),
|
|
268
|
+
* })
|
|
269
|
+
* const signature = await client.signMessage({
|
|
270
|
+
* message: 'hello world',
|
|
271
|
+
* })
|
|
272
|
+
*/
|
|
273
|
+
signMessage: (
|
|
274
|
+
args: Parameters<typeof signMessage<TSmartAccount>>[1]
|
|
275
|
+
) => ReturnType<typeof signMessage<TSmartAccount>>
|
|
276
|
+
/**
|
|
277
|
+
* Signs typed data and calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191): `keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))`.
|
|
278
|
+
*
|
|
279
|
+
* - Docs: https://viem.sh/docs/actions/wallet/signTypedData.html
|
|
280
|
+
* - JSON-RPC Methods:
|
|
281
|
+
* - JSON-RPC Accounts: [`eth_signTypedData_v4`](https://docs.metamask.io/guide/signing-data.html#signtypeddata-v4)
|
|
282
|
+
* - Local Accounts: Signs locally. No JSON-RPC request.
|
|
283
|
+
*
|
|
284
|
+
* @param client - Client to use
|
|
285
|
+
* @param args - {@link SignTypedDataParameters}
|
|
286
|
+
* @returns The signed data. {@link SignTypedDataReturnType}
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* import { createWalletClient, custom } from 'viem'
|
|
290
|
+
* import { mainnet } from 'viem/chains'
|
|
291
|
+
*
|
|
292
|
+
* const client = createWalletClient({
|
|
293
|
+
* chain: mainnet,
|
|
294
|
+
* transport: custom(window.ethereum),
|
|
295
|
+
* })
|
|
296
|
+
* const signature = await client.signTypedData({
|
|
297
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
298
|
+
* domain: {
|
|
299
|
+
* name: 'Ether Mail',
|
|
300
|
+
* version: '1',
|
|
301
|
+
* chainId: 1,
|
|
302
|
+
* verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
|
|
303
|
+
* },
|
|
304
|
+
* types: {
|
|
305
|
+
* Person: [
|
|
306
|
+
* { name: 'name', type: 'string' },
|
|
307
|
+
* { name: 'wallet', type: 'address' },
|
|
308
|
+
* ],
|
|
309
|
+
* Mail: [
|
|
310
|
+
* { name: 'from', type: 'Person' },
|
|
311
|
+
* { name: 'to', type: 'Person' },
|
|
312
|
+
* { name: 'contents', type: 'string' },
|
|
313
|
+
* ],
|
|
314
|
+
* },
|
|
315
|
+
* primaryType: 'Mail',
|
|
316
|
+
* message: {
|
|
317
|
+
* from: {
|
|
318
|
+
* name: 'Cow',
|
|
319
|
+
* wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
|
|
320
|
+
* },
|
|
321
|
+
* to: {
|
|
322
|
+
* name: 'Bob',
|
|
323
|
+
* wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
|
|
324
|
+
* },
|
|
325
|
+
* contents: 'Hello, Bob!',
|
|
326
|
+
* },
|
|
327
|
+
* })
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* // Account Hoisting
|
|
331
|
+
* import { createWalletClient, http } from 'viem'
|
|
332
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
333
|
+
* import { mainnet } from 'viem/chains'
|
|
334
|
+
*
|
|
335
|
+
* const client = createWalletClient({
|
|
336
|
+
* account: privateKeyToAccount('0x…'),
|
|
337
|
+
* chain: mainnet,
|
|
338
|
+
* transport: http(),
|
|
339
|
+
* })
|
|
340
|
+
* const signature = await client.signTypedData({
|
|
341
|
+
* domain: {
|
|
342
|
+
* name: 'Ether Mail',
|
|
343
|
+
* version: '1',
|
|
344
|
+
* chainId: 1,
|
|
345
|
+
* verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
|
|
346
|
+
* },
|
|
347
|
+
* types: {
|
|
348
|
+
* Person: [
|
|
349
|
+
* { name: 'name', type: 'string' },
|
|
350
|
+
* { name: 'wallet', type: 'address' },
|
|
351
|
+
* ],
|
|
352
|
+
* Mail: [
|
|
353
|
+
* { name: 'from', type: 'Person' },
|
|
354
|
+
* { name: 'to', type: 'Person' },
|
|
355
|
+
* { name: 'contents', type: 'string' },
|
|
356
|
+
* ],
|
|
357
|
+
* },
|
|
358
|
+
* primaryType: 'Mail',
|
|
359
|
+
* message: {
|
|
360
|
+
* from: {
|
|
361
|
+
* name: 'Cow',
|
|
362
|
+
* wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
|
|
363
|
+
* },
|
|
364
|
+
* to: {
|
|
365
|
+
* name: 'Bob',
|
|
366
|
+
* wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
|
|
367
|
+
* },
|
|
368
|
+
* contents: 'Hello, Bob!',
|
|
369
|
+
* },
|
|
370
|
+
* })
|
|
371
|
+
*/
|
|
372
|
+
signTypedData: <
|
|
373
|
+
const TTypedData extends TypedData | { [key: string]: unknown },
|
|
374
|
+
TPrimaryType extends string
|
|
189
375
|
>(
|
|
190
|
-
args:
|
|
191
|
-
|
|
192
|
-
|
|
376
|
+
args: Parameters<
|
|
377
|
+
typeof signTypedData<TTypedData, TPrimaryType, TSmartAccount>
|
|
378
|
+
>[1]
|
|
379
|
+
) => ReturnType<
|
|
380
|
+
typeof signTypedData<TTypedData, TPrimaryType, TSmartAccount>
|
|
381
|
+
>
|
|
382
|
+
/**
|
|
383
|
+
* Executes a write function on a contract.
|
|
384
|
+
* This function also allows you to sponsor this transaction if sender is a smartAccount
|
|
385
|
+
*
|
|
386
|
+
* - Docs: https://viem.sh/docs/contract/writeContract.html
|
|
387
|
+
* - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/contracts/writing-to-contracts
|
|
388
|
+
*
|
|
389
|
+
* A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a [Transaction](https://viem.sh/docs/glossary/terms.html) is needed to be broadcast in order to change the state.
|
|
390
|
+
*
|
|
391
|
+
* Internally, uses a [Wallet Client](https://viem.sh/docs/clients/wallet.html) to call the [`sendTransaction` action](https://viem.sh/docs/actions/wallet/sendTransaction.html) with [ABI-encoded `data`](https://viem.sh/docs/contract/encodeFunctionData.html).
|
|
392
|
+
*
|
|
393
|
+
* __Warning: The `write` internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to [simulate the contract write with `contract.simulate`](https://viem.sh/docs/contract/writeContract.html#usage) before you execute it.__
|
|
394
|
+
*
|
|
395
|
+
* @param args - {@link WriteContractParameters}
|
|
396
|
+
* @returns A [Transaction Hash](https://viem.sh/docs/glossary/terms.html#hash). {@link WriteContractReturnType}
|
|
397
|
+
*
|
|
398
|
+
* @example
|
|
399
|
+
* import { createWalletClient, custom, parseAbi } from 'viem'
|
|
400
|
+
* import { mainnet } from 'viem/chains'
|
|
401
|
+
*
|
|
402
|
+
* const client = createWalletClient({
|
|
403
|
+
* chain: mainnet,
|
|
404
|
+
* transport: custom(window.ethereum),
|
|
405
|
+
* })
|
|
406
|
+
* const hash = await client.writeContract({
|
|
407
|
+
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
|
408
|
+
* abi: parseAbi(['function mint(uint32 tokenId) nonpayable']),
|
|
409
|
+
* functionName: 'mint',
|
|
410
|
+
* args: [69420],
|
|
411
|
+
* })
|
|
412
|
+
*
|
|
413
|
+
* @example
|
|
414
|
+
* // With Validation
|
|
415
|
+
* import { createWalletClient, custom, parseAbi } from 'viem'
|
|
416
|
+
* import { mainnet } from 'viem/chains'
|
|
417
|
+
*
|
|
418
|
+
* const client = createWalletClient({
|
|
419
|
+
* chain: mainnet,
|
|
420
|
+
* transport: custom(window.ethereum),
|
|
421
|
+
* })
|
|
422
|
+
* const { request } = await client.simulateContract({
|
|
423
|
+
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
|
424
|
+
* abi: parseAbi(['function mint(uint32 tokenId) nonpayable']),
|
|
425
|
+
* functionName: 'mint',
|
|
426
|
+
* args: [69420],
|
|
427
|
+
* }
|
|
428
|
+
* const hash = await client.writeContract(request)
|
|
429
|
+
*/
|
|
430
|
+
writeContract: <
|
|
431
|
+
const TAbi extends Abi | readonly unknown[],
|
|
432
|
+
TFunctionName extends ContractFunctionName<
|
|
433
|
+
TAbi,
|
|
434
|
+
"nonpayable" | "payable"
|
|
435
|
+
> = ContractFunctionName<TAbi, "nonpayable" | "payable">,
|
|
436
|
+
TArgs extends ContractFunctionArgs<
|
|
437
|
+
TAbi,
|
|
438
|
+
"nonpayable" | "payable",
|
|
439
|
+
TFunctionName
|
|
440
|
+
> = ContractFunctionArgs<TAbi, "nonpayable" | "payable", TFunctionName>,
|
|
441
|
+
TChainOverride extends Chain | undefined = undefined
|
|
442
|
+
>(
|
|
443
|
+
args: WriteContractParameters<
|
|
444
|
+
TAbi,
|
|
445
|
+
TFunctionName,
|
|
446
|
+
TArgs,
|
|
447
|
+
TChain,
|
|
448
|
+
TSmartAccount,
|
|
449
|
+
TChainOverride
|
|
450
|
+
>
|
|
451
|
+
) => ReturnType<
|
|
452
|
+
typeof writeContract<
|
|
193
453
|
TChain,
|
|
194
454
|
TSmartAccount,
|
|
455
|
+
TAbi,
|
|
456
|
+
TFunctionName,
|
|
457
|
+
TArgs,
|
|
195
458
|
TChainOverride
|
|
196
459
|
>
|
|
197
|
-
|
|
460
|
+
>
|
|
198
461
|
}
|
|
199
462
|
|
|
200
|
-
export function kernelAccountClientActions
|
|
201
|
-
middleware
|
|
202
|
-
}: Middleware<entryPoint>) {
|
|
463
|
+
export function kernelAccountClientActions() {
|
|
203
464
|
return <
|
|
204
|
-
TTransport extends Transport,
|
|
205
465
|
TChain extends Chain | undefined = Chain | undefined,
|
|
206
|
-
TSmartAccount extends
|
|
207
|
-
|
|
|
208
|
-
| undefined =
|
|
209
|
-
| KernelSmartAccount<entryPoint, TTransport, TChain>
|
|
466
|
+
TSmartAccount extends SmartAccount | undefined =
|
|
467
|
+
| SmartAccount
|
|
210
468
|
| undefined
|
|
211
469
|
>(
|
|
212
|
-
client: Client<
|
|
213
|
-
): KernelAccountClientActions<
|
|
214
|
-
|
|
215
|
-
TTransport,
|
|
216
|
-
TChain,
|
|
217
|
-
TSmartAccount
|
|
218
|
-
> => ({
|
|
219
|
-
...smartAccountActions({ middleware })(client),
|
|
220
|
-
signUserOperation: (args) =>
|
|
221
|
-
signUserOperation<entryPoint, TTransport, TChain, TSmartAccount>(
|
|
222
|
-
client,
|
|
223
|
-
{
|
|
224
|
-
...args,
|
|
225
|
-
middleware
|
|
226
|
-
} as SignUserOperationParameters<
|
|
227
|
-
entryPoint,
|
|
228
|
-
TTransport,
|
|
229
|
-
TChain,
|
|
230
|
-
TSmartAccount
|
|
231
|
-
>
|
|
232
|
-
),
|
|
470
|
+
client: Client<Transport, TChain, TSmartAccount>
|
|
471
|
+
): KernelAccountClientActions<TChain, TSmartAccount> => ({
|
|
472
|
+
signUserOperation: (args) => signUserOperation(client, args),
|
|
233
473
|
getUserOperationGasPrice: async () => getUserOperationGasPrice(client),
|
|
234
|
-
uninstallPlugin: async (args) =>
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
TSmartAccount
|
|
245
|
-
>
|
|
246
|
-
),
|
|
247
|
-
changeSudoValidator: async (args) =>
|
|
248
|
-
changeSudoValidator<entryPoint, TTransport, TChain, TSmartAccount>(
|
|
249
|
-
client,
|
|
250
|
-
{
|
|
251
|
-
...args,
|
|
252
|
-
middleware
|
|
253
|
-
} as ChangeSudoValidatorParameters<
|
|
254
|
-
entryPoint,
|
|
255
|
-
TTransport,
|
|
256
|
-
TChain,
|
|
257
|
-
TSmartAccount
|
|
258
|
-
>
|
|
259
|
-
),
|
|
260
|
-
invalidateNonce: async (args) =>
|
|
261
|
-
invalidateNonce(client, {
|
|
262
|
-
...args,
|
|
263
|
-
middleware
|
|
264
|
-
} as InvalidateNonceParameters<
|
|
265
|
-
entryPoint,
|
|
266
|
-
TTransport,
|
|
267
|
-
TChain,
|
|
268
|
-
TSmartAccount
|
|
269
|
-
>),
|
|
270
|
-
getKernelV3ModuleCurrentNonce: async (args) =>
|
|
271
|
-
getKernelV3ModuleCurrentNonce(client, {
|
|
272
|
-
...args,
|
|
273
|
-
middleware
|
|
274
|
-
} as GetKernelV3ModuleCurrentNonceParameters<
|
|
275
|
-
entryPoint,
|
|
276
|
-
TTransport,
|
|
277
|
-
TChain,
|
|
278
|
-
TSmartAccount
|
|
279
|
-
>)
|
|
474
|
+
uninstallPlugin: async (args) => uninstallPlugin(client, args),
|
|
475
|
+
changeSudoValidator: async (args) => changeSudoValidator(client, args),
|
|
476
|
+
invalidateNonce: async (args) => invalidateNonce(client, args),
|
|
477
|
+
getKernelV3ModuleCurrentNonce: async () =>
|
|
478
|
+
getKernelV3ModuleCurrentNonce(client),
|
|
479
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
480
|
+
sendTransaction: (args) => sendTransaction(client, args as any),
|
|
481
|
+
signMessage: (args) => signMessage(client, args),
|
|
482
|
+
signTypedData: (args) => signTypedData(client, args),
|
|
483
|
+
writeContract: (args) => writeContract(client, args)
|
|
280
484
|
})
|
|
281
485
|
}
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type { KernelSmartAccount } from "../accounts/index.js"
|
|
1
|
+
import type { Chain, Client, RpcSchema, Transport } from "viem"
|
|
2
|
+
import type { SmartAccount } from "viem/account-abstraction"
|
|
4
3
|
import type { KernelAccountClient } from "./kernelAccountClient.js"
|
|
5
4
|
|
|
6
5
|
export const createFallbackKernelAccountClient = <
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
| undefined
|
|
6
|
+
transport extends Transport,
|
|
7
|
+
chain extends Chain | undefined = undefined,
|
|
8
|
+
account extends SmartAccount | undefined = undefined,
|
|
9
|
+
client extends Client | undefined = undefined,
|
|
10
|
+
rpcSchema extends RpcSchema | undefined = undefined
|
|
13
11
|
>(
|
|
14
12
|
clients: Array<
|
|
15
|
-
KernelAccountClient<
|
|
13
|
+
KernelAccountClient<transport, chain, account, client, rpcSchema>
|
|
16
14
|
>,
|
|
17
15
|
onError?: (error: Error, clientUrl: string) => Promise<void>
|
|
18
|
-
): KernelAccountClient<
|
|
16
|
+
): KernelAccountClient<transport, chain, account, client, rpcSchema> => {
|
|
19
17
|
// Function to create a fallback method for a given property.
|
|
20
18
|
// This method will try each client in sequence until one succeeds or all fail.
|
|
21
19
|
function createFallbackMethod(prop: PropertyKey) {
|