permissionless 0.1.30 → 0.1.32
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/CHANGELOG.md +15 -0
- package/_cjs/accounts/biconomy/privateKeyToBiconomySmartAccount.js.map +1 -1
- package/_cjs/accounts/biconomy/signerToBiconomySmartAccount.js +6 -5
- package/_cjs/accounts/biconomy/signerToBiconomySmartAccount.js.map +1 -1
- package/_cjs/accounts/index.js +5 -1
- package/_cjs/accounts/index.js.map +1 -1
- package/_cjs/accounts/kernel/signerToEcdsaKernelSmartAccount.js +42 -16
- package/_cjs/accounts/kernel/signerToEcdsaKernelSmartAccount.js.map +1 -1
- package/_cjs/accounts/kernel/utils/encodeCallData.js +2 -1
- package/_cjs/accounts/kernel/utils/encodeCallData.js.map +1 -1
- package/_cjs/accounts/kernel/utils/getNonceKey.js +2 -1
- package/_cjs/accounts/kernel/utils/getNonceKey.js.map +1 -1
- package/_cjs/accounts/kernel/utils/isKernelV2.js +9 -0
- package/_cjs/accounts/kernel/utils/isKernelV2.js.map +1 -0
- package/_cjs/accounts/kernel/utils/signMessage.js +2 -1
- package/_cjs/accounts/kernel/utils/signMessage.js.map +1 -1
- package/_cjs/accounts/kernel/utils/signTypedData.js +2 -1
- package/_cjs/accounts/kernel/utils/signTypedData.js.map +1 -1
- package/_cjs/accounts/kernel/utils/wrapMessageHash.js.map +1 -1
- package/_cjs/accounts/light/privateKeyToLightSmartAccount.js.map +1 -1
- package/_cjs/accounts/light/signerToLightSmartAccount.js +4 -3
- package/_cjs/accounts/light/signerToLightSmartAccount.js.map +1 -1
- package/_cjs/accounts/safe/privateKeyToSafeSmartAccount.js.map +1 -1
- package/_cjs/accounts/safe/signerToSafeSmartAccount.js +592 -175
- package/_cjs/accounts/safe/signerToSafeSmartAccount.js.map +1 -1
- package/_cjs/accounts/simple/privateKeyToSimpleSmartAccount.js.map +1 -1
- package/_cjs/accounts/simple/signerToSimpleSmartAccount.js +13 -3
- package/_cjs/accounts/simple/signerToSimpleSmartAccount.js.map +1 -1
- package/_cjs/accounts/toSmartAccount.js.map +1 -1
- package/_cjs/accounts/trust/privateKeyToTrustSmartAccount.js +14 -0
- package/_cjs/accounts/trust/privateKeyToTrustSmartAccount.js.map +1 -0
- package/_cjs/accounts/trust/signerToTrustSmartAccount.js +134 -0
- package/_cjs/accounts/trust/signerToTrustSmartAccount.js.map +1 -0
- package/_cjs/accounts/trust/utils/encodeCallData.js +74 -0
- package/_cjs/accounts/trust/utils/encodeCallData.js.map +1 -0
- package/_cjs/accounts/trust/utils/getAccountAddress.js +19 -0
- package/_cjs/accounts/trust/utils/getAccountAddress.js.map +1 -0
- package/_cjs/accounts/trust/utils/getDummySignature.js +8 -0
- package/_cjs/accounts/trust/utils/getDummySignature.js.map +1 -0
- package/_cjs/accounts/trust/utils/getFactoryData.js +43 -0
- package/_cjs/accounts/trust/utils/getFactoryData.js.map +1 -0
- package/_cjs/accounts/trust/utils/signMessage.js +9 -0
- package/_cjs/accounts/trust/utils/signMessage.js.map +1 -0
- package/_cjs/accounts/trust/utils/signTransaction.js +9 -0
- package/_cjs/accounts/trust/utils/signTransaction.js.map +1 -0
- package/_cjs/accounts/trust/utils/signUserOperation.js +19 -0
- package/_cjs/accounts/trust/utils/signUserOperation.js.map +1 -0
- package/_cjs/accounts/types.js.map +1 -1
- package/_cjs/actions/bundler/estimateUserOperationGas.js.map +1 -1
- package/_cjs/actions/bundler/waitForUserOperationReceipt.js +2 -2
- package/_cjs/actions/bundler/waitForUserOperationReceipt.js.map +1 -1
- package/_cjs/actions/erc7579/accountId.js +66 -0
- package/_cjs/actions/erc7579/accountId.js.map +1 -0
- package/_cjs/actions/erc7579/installModule.js +65 -0
- package/_cjs/actions/erc7579/installModule.js.map +1 -0
- package/_cjs/actions/erc7579/isModuleInstalled.js +86 -0
- package/_cjs/actions/erc7579/isModuleInstalled.js.map +1 -0
- package/_cjs/actions/erc7579/supportsExecutionMode.js +95 -0
- package/_cjs/actions/erc7579/supportsExecutionMode.js.map +1 -0
- package/_cjs/actions/erc7579/supportsModule.js +84 -0
- package/_cjs/actions/erc7579/supportsModule.js.map +1 -0
- package/_cjs/actions/erc7579/uninstallModule.js +65 -0
- package/_cjs/actions/erc7579/uninstallModule.js.map +1 -0
- package/_cjs/actions/erc7579.js +27 -0
- package/_cjs/actions/erc7579.js.map +1 -0
- package/_cjs/actions/smartAccount/deployContract.js.map +1 -1
- package/_cjs/actions/smartAccount/prepareUserOperationRequest.js +0 -3
- package/_cjs/actions/smartAccount/prepareUserOperationRequest.js.map +1 -1
- package/_cjs/actions/smartAccount/signTypedData.js.map +1 -1
- package/_cjs/errors/estimateUserOperationGas.js +6 -0
- package/_cjs/errors/estimateUserOperationGas.js.map +1 -1
- package/_cjs/utils/encode7579CallData.js +81 -0
- package/_cjs/utils/encode7579CallData.js.map +1 -0
- package/_cjs/utils/errors/getEstimateUserOperationGasError.js.map +1 -1
- package/_cjs/utils/errors/getSendUserOperationError.js.map +1 -1
- package/_cjs/vitest.config.js +31 -0
- package/_cjs/vitest.config.js.map +1 -0
- package/_esm/accounts/biconomy/privateKeyToBiconomySmartAccount.js +0 -1
- package/_esm/accounts/biconomy/privateKeyToBiconomySmartAccount.js.map +1 -1
- package/_esm/accounts/biconomy/signerToBiconomySmartAccount.js +6 -5
- package/_esm/accounts/biconomy/signerToBiconomySmartAccount.js.map +1 -1
- package/_esm/accounts/index.js +3 -1
- package/_esm/accounts/index.js.map +1 -1
- package/_esm/accounts/kernel/signerToEcdsaKernelSmartAccount.js +46 -20
- package/_esm/accounts/kernel/signerToEcdsaKernelSmartAccount.js.map +1 -1
- package/_esm/accounts/kernel/utils/encodeCallData.js +2 -2
- package/_esm/accounts/kernel/utils/encodeCallData.js.map +1 -1
- package/_esm/accounts/kernel/utils/getExecMode.js +0 -1
- package/_esm/accounts/kernel/utils/getExecMode.js.map +1 -1
- package/_esm/accounts/kernel/utils/getNonceKey.js +2 -2
- package/_esm/accounts/kernel/utils/getNonceKey.js.map +1 -1
- package/_esm/accounts/kernel/utils/isKernelV2.js +5 -0
- package/_esm/accounts/kernel/utils/isKernelV2.js.map +1 -0
- package/_esm/accounts/kernel/utils/signMessage.js +2 -1
- package/_esm/accounts/kernel/utils/signMessage.js.map +1 -1
- package/_esm/accounts/kernel/utils/signTypedData.js +2 -1
- package/_esm/accounts/kernel/utils/signTypedData.js.map +1 -1
- package/_esm/accounts/kernel/utils/wrapMessageHash.js.map +1 -1
- package/_esm/accounts/light/privateKeyToLightSmartAccount.js +2 -3
- package/_esm/accounts/light/privateKeyToLightSmartAccount.js.map +1 -1
- package/_esm/accounts/light/signerToLightSmartAccount.js +4 -3
- package/_esm/accounts/light/signerToLightSmartAccount.js.map +1 -1
- package/_esm/accounts/safe/privateKeyToSafeSmartAccount.js +0 -1
- package/_esm/accounts/safe/privateKeyToSafeSmartAccount.js.map +1 -1
- package/_esm/accounts/safe/signerToSafeSmartAccount.js +594 -176
- package/_esm/accounts/safe/signerToSafeSmartAccount.js.map +1 -1
- package/_esm/accounts/simple/privateKeyToSimpleSmartAccount.js +0 -1
- package/_esm/accounts/simple/privateKeyToSimpleSmartAccount.js.map +1 -1
- package/_esm/accounts/simple/signerToSimpleSmartAccount.js +13 -3
- package/_esm/accounts/simple/signerToSimpleSmartAccount.js.map +1 -1
- package/_esm/accounts/toSmartAccount.js.map +1 -1
- package/_esm/accounts/trust/privateKeyToTrustSmartAccount.js +15 -0
- package/_esm/accounts/trust/privateKeyToTrustSmartAccount.js.map +1 -0
- package/_esm/accounts/trust/signerToTrustSmartAccount.js +138 -0
- package/_esm/accounts/trust/signerToTrustSmartAccount.js.map +1 -0
- package/_esm/accounts/trust/utils/encodeCallData.js +70 -0
- package/_esm/accounts/trust/utils/encodeCallData.js.map +1 -0
- package/_esm/accounts/trust/utils/getAccountAddress.js +15 -0
- package/_esm/accounts/trust/utils/getAccountAddress.js.map +1 -0
- package/_esm/accounts/trust/utils/getDummySignature.js +4 -0
- package/_esm/accounts/trust/utils/getDummySignature.js.map +1 -0
- package/_esm/accounts/trust/utils/getFactoryData.js +42 -0
- package/_esm/accounts/trust/utils/getFactoryData.js.map +1 -0
- package/_esm/accounts/trust/utils/signMessage.js +5 -0
- package/_esm/accounts/trust/utils/signMessage.js.map +1 -0
- package/_esm/accounts/trust/utils/signTransaction.js +5 -0
- package/_esm/accounts/trust/utils/signTransaction.js.map +1 -0
- package/_esm/accounts/trust/utils/signUserOperation.js +15 -0
- package/_esm/accounts/trust/utils/signUserOperation.js.map +1 -0
- package/_esm/accounts/types.js.map +1 -1
- package/_esm/actions/bundler/estimateUserOperationGas.js +0 -1
- package/_esm/actions/bundler/estimateUserOperationGas.js.map +1 -1
- package/_esm/actions/bundler/waitForUserOperationReceipt.js +2 -2
- package/_esm/actions/bundler/waitForUserOperationReceipt.js.map +1 -1
- package/_esm/actions/erc7579/accountId.js +62 -0
- package/_esm/actions/erc7579/accountId.js.map +1 -0
- package/_esm/actions/erc7579/installModule.js +61 -0
- package/_esm/actions/erc7579/installModule.js.map +1 -0
- package/_esm/actions/erc7579/isModuleInstalled.js +82 -0
- package/_esm/actions/erc7579/isModuleInstalled.js.map +1 -0
- package/_esm/actions/erc7579/supportsExecutionMode.js +90 -0
- package/_esm/actions/erc7579/supportsExecutionMode.js.map +1 -0
- package/_esm/actions/erc7579/supportsModule.js +79 -0
- package/_esm/actions/erc7579/supportsModule.js.map +1 -0
- package/_esm/actions/erc7579/uninstallModule.js +61 -0
- package/_esm/actions/erc7579/uninstallModule.js.map +1 -0
- package/_esm/actions/erc7579.js +18 -0
- package/_esm/actions/erc7579.js.map +1 -0
- package/_esm/actions/pimlico/sendCompressedUserOperation.js +0 -1
- package/_esm/actions/pimlico/sendCompressedUserOperation.js.map +1 -1
- package/_esm/actions/smartAccount/deployContract.js +0 -1
- package/_esm/actions/smartAccount/deployContract.js.map +1 -1
- package/_esm/actions/smartAccount/prepareUserOperationRequest.js +0 -3
- package/_esm/actions/smartAccount/prepareUserOperationRequest.js.map +1 -1
- package/_esm/actions/smartAccount/signMessage.js +0 -1
- package/_esm/actions/smartAccount/signMessage.js.map +1 -1
- package/_esm/actions/smartAccount/signTypedData.js.map +1 -1
- package/_esm/actions/stackup/sponsorUserOperation.js +0 -1
- package/_esm/actions/stackup/sponsorUserOperation.js.map +1 -1
- package/_esm/clients/createSmartAccountClient.js +0 -3
- package/_esm/clients/createSmartAccountClient.js.map +1 -1
- package/_esm/clients/decorators/stackup.js +0 -1
- package/_esm/clients/decorators/stackup.js.map +1 -1
- package/_esm/errors/estimateUserOperationGas.js +6 -0
- package/_esm/errors/estimateUserOperationGas.js.map +1 -1
- package/_esm/index.js +0 -1
- package/_esm/index.js.map +1 -1
- package/_esm/utils/encode7579CallData.js +77 -0
- package/_esm/utils/encode7579CallData.js.map +1 -0
- package/_esm/utils/errors/getEstimateUserOperationGasError.js +1 -2
- package/_esm/utils/errors/getEstimateUserOperationGasError.js.map +1 -1
- package/_esm/utils/errors/getSendUserOperationError.js +1 -1
- package/_esm/utils/errors/getSendUserOperationError.js.map +1 -1
- package/_esm/vitest.config.js +29 -0
- package/_esm/vitest.config.js.map +1 -0
- package/_types/accounts/biconomy/privateKeyToBiconomySmartAccount.d.ts +2 -2
- package/_types/accounts/biconomy/privateKeyToBiconomySmartAccount.d.ts.map +1 -1
- package/_types/accounts/biconomy/signerToBiconomySmartAccount.d.ts +3 -1
- package/_types/accounts/biconomy/signerToBiconomySmartAccount.d.ts.map +1 -1
- package/_types/accounts/index.d.ts +3 -1
- package/_types/accounts/index.d.ts.map +1 -1
- package/_types/accounts/kernel/signerToEcdsaKernelSmartAccount.d.ts +7 -3
- package/_types/accounts/kernel/signerToEcdsaKernelSmartAccount.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/encodeCallData.d.ts +3 -2
- package/_types/accounts/kernel/utils/encodeCallData.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/getExecMode.d.ts +1 -1
- package/_types/accounts/kernel/utils/getExecMode.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/getNonceKey.d.ts +3 -2
- package/_types/accounts/kernel/utils/getNonceKey.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/isKernelV2.d.ts +4 -0
- package/_types/accounts/kernel/utils/isKernelV2.d.ts.map +1 -0
- package/_types/accounts/kernel/utils/signMessage.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/signTypedData.d.ts.map +1 -1
- package/_types/accounts/kernel/utils/wrapMessageHash.d.ts +3 -1
- package/_types/accounts/kernel/utils/wrapMessageHash.d.ts.map +1 -1
- package/_types/accounts/light/privateKeyToLightSmartAccount.d.ts +7 -6
- package/_types/accounts/light/privateKeyToLightSmartAccount.d.ts.map +1 -1
- package/_types/accounts/light/signerToLightSmartAccount.d.ts +3 -2
- package/_types/accounts/light/signerToLightSmartAccount.d.ts.map +1 -1
- package/_types/accounts/safe/privateKeyToSafeSmartAccount.d.ts +4 -4
- package/_types/accounts/safe/privateKeyToSafeSmartAccount.d.ts.map +1 -1
- package/_types/accounts/safe/signerToSafeSmartAccount.d.ts +38 -15
- package/_types/accounts/safe/signerToSafeSmartAccount.d.ts.map +1 -1
- package/_types/accounts/simple/privateKeyToSimpleSmartAccount.d.ts +2 -2
- package/_types/accounts/simple/privateKeyToSimpleSmartAccount.d.ts.map +1 -1
- package/_types/accounts/simple/signerToSimpleSmartAccount.d.ts +4 -3
- package/_types/accounts/simple/signerToSimpleSmartAccount.d.ts.map +1 -1
- package/_types/accounts/toSmartAccount.d.ts +3 -3
- package/_types/accounts/toSmartAccount.d.ts.map +1 -1
- package/_types/accounts/trust/privateKeyToTrustSmartAccount.d.ts +13 -0
- package/_types/accounts/trust/privateKeyToTrustSmartAccount.d.ts.map +1 -0
- package/_types/accounts/trust/signerToTrustSmartAccount.d.ts +27 -0
- package/_types/accounts/trust/signerToTrustSmartAccount.d.ts.map +1 -0
- package/_types/accounts/trust/utils/encodeCallData.d.ts +12 -0
- package/_types/accounts/trust/utils/encodeCallData.d.ts.map +1 -0
- package/_types/accounts/trust/utils/getAccountAddress.d.ts +10 -0
- package/_types/accounts/trust/utils/getAccountAddress.d.ts.map +1 -0
- package/_types/accounts/trust/utils/getDummySignature.d.ts +3 -0
- package/_types/accounts/trust/utils/getDummySignature.d.ts.map +1 -0
- package/_types/accounts/trust/utils/getFactoryData.d.ts +10 -0
- package/_types/accounts/trust/utils/getFactoryData.d.ts.map +1 -0
- package/_types/accounts/trust/utils/signMessage.d.ts +4 -0
- package/_types/accounts/trust/utils/signMessage.d.ts.map +1 -0
- package/_types/accounts/trust/utils/signTransaction.d.ts +5 -0
- package/_types/accounts/trust/utils/signTransaction.d.ts.map +1 -0
- package/_types/accounts/trust/utils/signUserOperation.d.ts +9 -0
- package/_types/accounts/trust/utils/signUserOperation.d.ts.map +1 -0
- package/_types/accounts/types.d.ts +3 -3
- package/_types/accounts/types.d.ts.map +1 -1
- package/_types/actions/bundler/chainId.d.ts.map +1 -1
- package/_types/actions/bundler/estimateUserOperationGas.d.ts +42 -3
- package/_types/actions/bundler/estimateUserOperationGas.d.ts.map +1 -1
- package/_types/actions/bundler/getUserOperationByHash.d.ts +1 -7
- package/_types/actions/bundler/getUserOperationByHash.d.ts.map +1 -1
- package/_types/actions/bundler/getUserOperationReceipt.d.ts.map +1 -1
- package/_types/actions/bundler/sendUserOperation.d.ts +4 -1
- package/_types/actions/bundler/sendUserOperation.d.ts.map +1 -1
- package/_types/actions/bundler/supportedEntryPoints.d.ts.map +1 -1
- package/_types/actions/bundler/waitForUserOperationReceipt.d.ts.map +1 -1
- package/_types/actions/erc7579/accountId.d.ts +6 -0
- package/_types/actions/erc7579/accountId.d.ts.map +1 -0
- package/_types/actions/erc7579/installModule.d.ts +16 -0
- package/_types/actions/erc7579/installModule.d.ts.map +1 -0
- package/_types/actions/erc7579/isModuleInstalled.d.ts +12 -0
- package/_types/actions/erc7579/isModuleInstalled.d.ts.map +1 -0
- package/_types/actions/erc7579/supportsExecutionMode.d.ts +15 -0
- package/_types/actions/erc7579/supportsExecutionMode.d.ts.map +1 -0
- package/_types/actions/erc7579/supportsModule.d.ts +11 -0
- package/_types/actions/erc7579/supportsModule.d.ts.map +1 -0
- package/_types/actions/erc7579/uninstallModule.d.ts +16 -0
- package/_types/actions/erc7579/uninstallModule.d.ts.map +1 -0
- package/_types/actions/erc7579.d.ts +26 -0
- package/_types/actions/erc7579.d.ts.map +1 -0
- package/_types/actions/pimlico/getUserOperationGasPrice.d.ts.map +1 -1
- package/_types/actions/pimlico/getUserOperationStatus.d.ts.map +1 -1
- package/_types/actions/pimlico/sendCompressedUserOperation.d.ts +1 -1
- package/_types/actions/pimlico/sendCompressedUserOperation.d.ts.map +1 -1
- package/_types/actions/pimlico/sponsorUserOperation.d.ts +1 -41
- package/_types/actions/pimlico/sponsorUserOperation.d.ts.map +1 -1
- package/_types/actions/pimlico/validateSponsorshipPolicies.d.ts +1 -5
- package/_types/actions/pimlico/validateSponsorshipPolicies.d.ts.map +1 -1
- package/_types/actions/public/getAccountNonce.d.ts.map +1 -1
- package/_types/actions/public/getSenderAddress.d.ts +1 -1
- package/_types/actions/public/getSenderAddress.d.ts.map +1 -1
- package/_types/actions/smartAccount/deployContract.d.ts +2 -2
- package/_types/actions/smartAccount/deployContract.d.ts.map +1 -1
- package/_types/actions/smartAccount/prepareUserOperationRequest.d.ts.map +1 -1
- package/_types/actions/smartAccount/signMessage.d.ts +1 -1
- package/_types/actions/smartAccount/signMessage.d.ts.map +1 -1
- package/_types/actions/smartAccount/signTypedData.d.ts.map +1 -1
- package/_types/actions/stackup/accounts.d.ts.map +1 -1
- package/_types/actions/stackup/sponsorUserOperation.d.ts +1 -1
- package/_types/actions/stackup/sponsorUserOperation.d.ts.map +1 -1
- package/_types/clients/createBundlerClient.d.ts +2 -18
- package/_types/clients/createBundlerClient.d.ts.map +1 -1
- package/_types/clients/createSmartAccountClient.d.ts +3 -3
- package/_types/clients/createSmartAccountClient.d.ts.map +1 -1
- package/_types/clients/decorators/bundler.d.ts.map +1 -1
- package/_types/clients/decorators/pimlico.d.ts.map +1 -1
- package/_types/clients/decorators/smartAccount.d.ts.map +1 -1
- package/_types/clients/decorators/stackup.d.ts.map +1 -1
- package/_types/clients/pimlico.d.ts +2 -34
- package/_types/clients/pimlico.d.ts.map +1 -1
- package/_types/clients/stackup.d.ts +1 -17
- package/_types/clients/stackup.d.ts.map +1 -1
- package/_types/errors/estimateUserOperationGas.d.ts.map +1 -1
- package/_types/experimental/eip7677/clients/decorators/paymasterActionsEip7677.d.ts.map +1 -1
- package/_types/index.d.ts +1 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/types/index.d.ts +2 -2
- package/_types/types/index.d.ts.map +1 -1
- package/_types/utils/encode7579CallData.d.ts +16 -0
- package/_types/utils/encode7579CallData.d.ts.map +1 -0
- package/_types/utils/errors/getEstimateUserOperationGasError.d.ts +1 -1
- package/_types/utils/errors/getEstimateUserOperationGasError.d.ts.map +1 -1
- package/_types/utils/errors/getSendUserOperationError.d.ts +1 -1
- package/_types/utils/errors/getSendUserOperationError.d.ts.map +1 -1
- package/_types/utils/getRequiredPrefund.d.ts.map +1 -1
- package/_types/utils/getUserOperationHash.d.ts.map +1 -1
- package/_types/utils/signUserOperationHashWithECDSA.d.ts.map +1 -1
- package/_types/vitest.config.d.ts +3 -0
- package/_types/vitest.config.d.ts.map +1 -0
- package/accounts/biconomy/privateKeyToBiconomySmartAccount.ts +15 -2
- package/accounts/biconomy/signerToBiconomySmartAccount.ts +22 -7
- package/accounts/index.ts +17 -1
- package/accounts/kernel/signerToEcdsaKernelSmartAccount.ts +80 -35
- package/accounts/kernel/utils/encodeCallData.ts +5 -3
- package/accounts/kernel/utils/getExecMode.ts +1 -1
- package/accounts/kernel/utils/getNonceKey.ts +5 -3
- package/accounts/kernel/utils/isKernelV2.ts +7 -0
- package/accounts/kernel/utils/signMessage.ts +2 -1
- package/accounts/kernel/utils/signTypedData.ts +2 -1
- package/accounts/kernel/utils/wrapMessageHash.ts +3 -1
- package/accounts/light/privateKeyToLightSmartAccount.ts +21 -7
- package/accounts/light/signerToLightSmartAccount.ts +15 -4
- package/accounts/safe/privateKeyToSafeSmartAccount.ts +18 -5
- package/accounts/safe/signerToSafeSmartAccount.ts +776 -200
- package/accounts/simple/privateKeyToSimpleSmartAccount.ts +15 -7
- package/accounts/simple/signerToSimpleSmartAccount.ts +30 -6
- package/accounts/toSmartAccount.ts +5 -3
- package/accounts/trust/privateKeyToTrustSmartAccount.ts +50 -0
- package/accounts/trust/signerToTrustSmartAccount.ts +242 -0
- package/accounts/trust/utils/encodeCallData.ts +95 -0
- package/accounts/trust/utils/getAccountAddress.ts +42 -0
- package/accounts/trust/utils/getDummySignature.ts +12 -0
- package/accounts/trust/utils/getFactoryData.ts +51 -0
- package/accounts/trust/utils/signMessage.ts +13 -0
- package/accounts/trust/utils/signTransaction.ts +15 -0
- package/accounts/trust/utils/signUserOperation.ts +38 -0
- package/accounts/types.ts +9 -3
- package/actions/bundler/chainId.test.ts +25 -0
- package/actions/bundler/estimateUserOperationGas.test.ts +205 -0
- package/actions/bundler/estimateUserOperationGas.ts +2 -9
- package/actions/bundler/getUserOperationByHash.test.ts +139 -0
- package/actions/bundler/getUserOperationReceipt.test.ts +127 -0
- package/actions/bundler/sendUserOperation.test.ts +126 -0
- package/actions/bundler/supportedEntryPoints.test.ts +27 -0
- package/actions/bundler/waitForUserOperationReceipt.test.ts +130 -0
- package/actions/bundler/waitForUserOperationReceipt.ts +2 -2
- package/actions/erc7579/accountId.test.ts +52 -0
- package/actions/erc7579/accountId.ts +91 -0
- package/actions/erc7579/installModule.test.ts +124 -0
- package/actions/erc7579/installModule.ts +109 -0
- package/actions/erc7579/isModuleInstalled.test.ts +119 -0
- package/actions/erc7579/isModuleInstalled.ts +122 -0
- package/actions/erc7579/supportsExecutionMode.test.ts +72 -0
- package/actions/erc7579/supportsExecutionMode.ts +154 -0
- package/actions/erc7579/supportsModule.test.ts +46 -0
- package/actions/erc7579/supportsModule.ts +117 -0
- package/actions/erc7579/uninstallModule.test.ts +158 -0
- package/actions/erc7579/uninstallModule.ts +113 -0
- package/actions/erc7579.ts +114 -0
- package/actions/index.test.ts +329 -0
- package/actions/pimlico/getUserOperationGasPrice.test.ts +33 -0
- package/actions/pimlico/getUserOperationStatus.test.ts +152 -0
- package/actions/pimlico/sendCompressedUserOperation.ts +1 -1
- package/actions/pimlico/sponsorUserOperation.test.ts +126 -0
- package/actions/pimlico/validateSponsorshipPolicies.test.ts +56 -0
- package/actions/pimlico.test.ts +222 -0
- package/actions/public/getAccountNonce.test.ts +52 -0
- package/actions/public/getSenderAddress.test.ts +83 -0
- package/actions/smartAccount/deployContract.test.ts +118 -0
- package/actions/smartAccount/deployContract.ts +4 -2
- package/actions/smartAccount/prepareUserOperationRequest.test.ts +151 -0
- package/actions/smartAccount/prepareUserOperationRequest.ts +0 -4
- package/actions/smartAccount/sendTransaction.test.ts +108 -0
- package/actions/smartAccount/sendTransactions.test.ts +126 -0
- package/actions/smartAccount/sendUserOperation.test.ts +133 -0
- package/actions/smartAccount/signMessage.test.ts +89 -0
- package/actions/smartAccount/signMessage.ts +1 -1
- package/actions/smartAccount/signTypedData.test.ts +118 -0
- package/actions/smartAccount/signTypedData.ts +4 -2
- package/actions/smartAccount/writeContract.test.ts +118 -0
- package/actions/stackup/sponsorUserOperation.ts +1 -1
- package/clients/createSmartAccountClient.ts +3 -3
- package/clients/decorators/stackup.ts +1 -1
- package/errors/estimateUserOperationGas.ts +7 -0
- package/experimental/eip7677/actions/getPaymasterData.test.ts +137 -0
- package/experimental/eip7677/actions/getPaymasterStubData.test.ts +84 -0
- package/index.ts +1 -1
- package/package.json +7 -2
- package/types/index.ts +3 -4
- package/utils/encode7579CallData.ts +114 -0
- package/utils/errors/getEstimateUserOperationGasError.ts +2 -2
- package/utils/errors/getSendUserOperationError.ts +1 -1
- package/vitest.config.ts +29 -0
|
@@ -4,10 +4,337 @@ exports.signerToSafeSmartAccount = void 0;
|
|
|
4
4
|
const viem_1 = require("viem");
|
|
5
5
|
const actions_1 = require("viem/actions");
|
|
6
6
|
const getAccountNonce_1 = require("../../actions/public/getAccountNonce.js");
|
|
7
|
+
const encode7579CallData_1 = require("../../utils/encode7579CallData.js");
|
|
7
8
|
const getEntryPointVersion_1 = require("../../utils/getEntryPointVersion.js");
|
|
8
9
|
const isSmartAccountDeployed_1 = require("../../utils/isSmartAccountDeployed.js");
|
|
9
10
|
const toSmartAccount_1 = require("../toSmartAccount.js");
|
|
10
11
|
const types_1 = require("../types.js");
|
|
12
|
+
const multiSendAbi = [
|
|
13
|
+
{
|
|
14
|
+
inputs: [
|
|
15
|
+
{
|
|
16
|
+
internalType: "bytes",
|
|
17
|
+
name: "transactions",
|
|
18
|
+
type: "bytes"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
name: "multiSend",
|
|
22
|
+
outputs: [],
|
|
23
|
+
stateMutability: "payable",
|
|
24
|
+
type: "function"
|
|
25
|
+
}
|
|
26
|
+
];
|
|
27
|
+
const initSafe7579Abi = [
|
|
28
|
+
{
|
|
29
|
+
type: "function",
|
|
30
|
+
name: "initSafe7579",
|
|
31
|
+
inputs: [
|
|
32
|
+
{
|
|
33
|
+
name: "safe7579",
|
|
34
|
+
type: "address",
|
|
35
|
+
internalType: "address"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "executors",
|
|
39
|
+
type: "tuple[]",
|
|
40
|
+
internalType: "struct ModuleInit[]",
|
|
41
|
+
components: [
|
|
42
|
+
{
|
|
43
|
+
name: "module",
|
|
44
|
+
type: "address",
|
|
45
|
+
internalType: "address"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "initData",
|
|
49
|
+
type: "bytes",
|
|
50
|
+
internalType: "bytes"
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "fallbacks",
|
|
56
|
+
type: "tuple[]",
|
|
57
|
+
internalType: "struct ModuleInit[]",
|
|
58
|
+
components: [
|
|
59
|
+
{
|
|
60
|
+
name: "module",
|
|
61
|
+
type: "address",
|
|
62
|
+
internalType: "address"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "initData",
|
|
66
|
+
type: "bytes",
|
|
67
|
+
internalType: "bytes"
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "hooks",
|
|
73
|
+
type: "tuple[]",
|
|
74
|
+
internalType: "struct ModuleInit[]",
|
|
75
|
+
components: [
|
|
76
|
+
{
|
|
77
|
+
name: "module",
|
|
78
|
+
type: "address",
|
|
79
|
+
internalType: "address"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "initData",
|
|
83
|
+
type: "bytes",
|
|
84
|
+
internalType: "bytes"
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: "attesters",
|
|
90
|
+
type: "address[]",
|
|
91
|
+
internalType: "address[]"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: "threshold",
|
|
95
|
+
type: "uint8",
|
|
96
|
+
internalType: "uint8"
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
outputs: [],
|
|
100
|
+
stateMutability: "nonpayable"
|
|
101
|
+
}
|
|
102
|
+
];
|
|
103
|
+
const preValidationSetupAbi = [
|
|
104
|
+
{
|
|
105
|
+
type: "function",
|
|
106
|
+
name: "preValidationSetup",
|
|
107
|
+
inputs: [
|
|
108
|
+
{
|
|
109
|
+
name: "initHash",
|
|
110
|
+
type: "bytes32",
|
|
111
|
+
internalType: "bytes32"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "to",
|
|
115
|
+
type: "address",
|
|
116
|
+
internalType: "address"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "preInit",
|
|
120
|
+
type: "bytes",
|
|
121
|
+
internalType: "bytes"
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
outputs: [],
|
|
125
|
+
stateMutability: "nonpayable"
|
|
126
|
+
}
|
|
127
|
+
];
|
|
128
|
+
const enableModulesAbi = [
|
|
129
|
+
{
|
|
130
|
+
inputs: [
|
|
131
|
+
{
|
|
132
|
+
internalType: "address[]",
|
|
133
|
+
name: "modules",
|
|
134
|
+
type: "address[]"
|
|
135
|
+
}
|
|
136
|
+
],
|
|
137
|
+
name: "enableModules",
|
|
138
|
+
outputs: [],
|
|
139
|
+
stateMutability: "nonpayable",
|
|
140
|
+
type: "function"
|
|
141
|
+
}
|
|
142
|
+
];
|
|
143
|
+
const setupAbi = [
|
|
144
|
+
{
|
|
145
|
+
inputs: [
|
|
146
|
+
{
|
|
147
|
+
internalType: "address[]",
|
|
148
|
+
name: "_owners",
|
|
149
|
+
type: "address[]"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
internalType: "uint256",
|
|
153
|
+
name: "_threshold",
|
|
154
|
+
type: "uint256"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
internalType: "address",
|
|
158
|
+
name: "to",
|
|
159
|
+
type: "address"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
internalType: "bytes",
|
|
163
|
+
name: "data",
|
|
164
|
+
type: "bytes"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
internalType: "address",
|
|
168
|
+
name: "fallbackHandler",
|
|
169
|
+
type: "address"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
internalType: "address",
|
|
173
|
+
name: "paymentToken",
|
|
174
|
+
type: "address"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
internalType: "uint256",
|
|
178
|
+
name: "payment",
|
|
179
|
+
type: "uint256"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
internalType: "address payable",
|
|
183
|
+
name: "paymentReceiver",
|
|
184
|
+
type: "address"
|
|
185
|
+
}
|
|
186
|
+
],
|
|
187
|
+
name: "setup",
|
|
188
|
+
outputs: [],
|
|
189
|
+
stateMutability: "nonpayable",
|
|
190
|
+
type: "function"
|
|
191
|
+
}
|
|
192
|
+
];
|
|
193
|
+
const createProxyWithNonceAbi = [
|
|
194
|
+
{
|
|
195
|
+
inputs: [
|
|
196
|
+
{
|
|
197
|
+
internalType: "address",
|
|
198
|
+
name: "_singleton",
|
|
199
|
+
type: "address"
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
internalType: "bytes",
|
|
203
|
+
name: "initializer",
|
|
204
|
+
type: "bytes"
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
internalType: "uint256",
|
|
208
|
+
name: "saltNonce",
|
|
209
|
+
type: "uint256"
|
|
210
|
+
}
|
|
211
|
+
],
|
|
212
|
+
name: "createProxyWithNonce",
|
|
213
|
+
outputs: [
|
|
214
|
+
{
|
|
215
|
+
internalType: "contract SafeProxy",
|
|
216
|
+
name: "proxy",
|
|
217
|
+
type: "address"
|
|
218
|
+
}
|
|
219
|
+
],
|
|
220
|
+
stateMutability: "nonpayable",
|
|
221
|
+
type: "function"
|
|
222
|
+
}
|
|
223
|
+
];
|
|
224
|
+
const proxyCreationCodeAbi = [
|
|
225
|
+
{
|
|
226
|
+
inputs: [],
|
|
227
|
+
name: "proxyCreationCode",
|
|
228
|
+
outputs: [
|
|
229
|
+
{
|
|
230
|
+
internalType: "bytes",
|
|
231
|
+
name: "",
|
|
232
|
+
type: "bytes"
|
|
233
|
+
}
|
|
234
|
+
],
|
|
235
|
+
stateMutability: "pure",
|
|
236
|
+
type: "function"
|
|
237
|
+
}
|
|
238
|
+
];
|
|
239
|
+
const setupSafeAbi = [
|
|
240
|
+
{
|
|
241
|
+
type: "function",
|
|
242
|
+
name: "setupSafe",
|
|
243
|
+
inputs: [
|
|
244
|
+
{
|
|
245
|
+
name: "initData",
|
|
246
|
+
type: "tuple",
|
|
247
|
+
internalType: "struct Safe7579Launchpad.InitData",
|
|
248
|
+
components: [
|
|
249
|
+
{
|
|
250
|
+
name: "singleton",
|
|
251
|
+
type: "address",
|
|
252
|
+
internalType: "address"
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
name: "owners",
|
|
256
|
+
type: "address[]",
|
|
257
|
+
internalType: "address[]"
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
name: "threshold",
|
|
261
|
+
type: "uint256",
|
|
262
|
+
internalType: "uint256"
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
name: "setupTo",
|
|
266
|
+
type: "address",
|
|
267
|
+
internalType: "address"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
name: "setupData",
|
|
271
|
+
type: "bytes",
|
|
272
|
+
internalType: "bytes"
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
name: "safe7579",
|
|
276
|
+
type: "address",
|
|
277
|
+
internalType: "contract ISafe7579"
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
name: "validators",
|
|
281
|
+
type: "tuple[]",
|
|
282
|
+
internalType: "struct ModuleInit[]",
|
|
283
|
+
components: [
|
|
284
|
+
{
|
|
285
|
+
name: "module",
|
|
286
|
+
type: "address",
|
|
287
|
+
internalType: "address"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
name: "initData",
|
|
291
|
+
type: "bytes",
|
|
292
|
+
internalType: "bytes"
|
|
293
|
+
}
|
|
294
|
+
]
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
name: "callData",
|
|
298
|
+
type: "bytes",
|
|
299
|
+
internalType: "bytes"
|
|
300
|
+
}
|
|
301
|
+
]
|
|
302
|
+
}
|
|
303
|
+
],
|
|
304
|
+
outputs: [],
|
|
305
|
+
stateMutability: "nonpayable"
|
|
306
|
+
}
|
|
307
|
+
];
|
|
308
|
+
const executeUserOpWithErrorStringAbi = [
|
|
309
|
+
{
|
|
310
|
+
inputs: [
|
|
311
|
+
{
|
|
312
|
+
internalType: "address",
|
|
313
|
+
name: "to",
|
|
314
|
+
type: "address"
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
internalType: "uint256",
|
|
318
|
+
name: "value",
|
|
319
|
+
type: "uint256"
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
internalType: "bytes",
|
|
323
|
+
name: "data",
|
|
324
|
+
type: "bytes"
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
internalType: "uint8",
|
|
328
|
+
name: "operation",
|
|
329
|
+
type: "uint8"
|
|
330
|
+
}
|
|
331
|
+
],
|
|
332
|
+
name: "executeUserOpWithErrorString",
|
|
333
|
+
outputs: [],
|
|
334
|
+
stateMutability: "nonpayable",
|
|
335
|
+
type: "function"
|
|
336
|
+
}
|
|
337
|
+
];
|
|
11
338
|
const EIP712_SAFE_OPERATION_TYPE_V06 = {
|
|
12
339
|
SafeOp: [
|
|
13
340
|
{ type: "address", name: "safe" },
|
|
@@ -65,7 +392,7 @@ const SAFE_VERSION_TO_ADDRESSES_MAP = {
|
|
|
65
392
|
const adjustVInSignature = (signingMethod, signature) => {
|
|
66
393
|
const ETHEREUM_V_VALUES = [0, 1, 27, 28];
|
|
67
394
|
const MIN_VALID_V_VALUE_FOR_SAFE_ECDSA = 27;
|
|
68
|
-
let signatureV = parseInt(signature.slice(-2), 16);
|
|
395
|
+
let signatureV = Number.parseInt(signature.slice(-2), 16);
|
|
69
396
|
if (!ETHEREUM_V_VALUES.includes(signatureV)) {
|
|
70
397
|
throw new Error("Invalid signature");
|
|
71
398
|
}
|
|
@@ -104,45 +431,128 @@ const encodeMultiSend = (txs) => {
|
|
|
104
431
|
.map((tx) => encodeInternalTransaction(tx))
|
|
105
432
|
.join("")}`;
|
|
106
433
|
return (0, viem_1.encodeFunctionData)({
|
|
107
|
-
abi:
|
|
434
|
+
abi: multiSendAbi,
|
|
435
|
+
functionName: "multiSend",
|
|
436
|
+
args: [data]
|
|
437
|
+
});
|
|
438
|
+
};
|
|
439
|
+
const get7579LaunchPadInitData = ({ safe4337ModuleAddress, safeSingletonAddress, erc7569LaunchpadAddress, owner, validators, executors, fallbacks, hooks, attesters, attestersThreshold }) => {
|
|
440
|
+
const initData = {
|
|
441
|
+
singleton: safeSingletonAddress,
|
|
442
|
+
owners: [owner],
|
|
443
|
+
threshold: BigInt(1),
|
|
444
|
+
setupTo: erc7569LaunchpadAddress,
|
|
445
|
+
setupData: (0, viem_1.encodeFunctionData)({
|
|
446
|
+
abi: initSafe7579Abi,
|
|
447
|
+
functionName: "initSafe7579",
|
|
448
|
+
args: [
|
|
449
|
+
safe4337ModuleAddress,
|
|
450
|
+
executors.map((executor) => ({
|
|
451
|
+
module: executor.address,
|
|
452
|
+
initData: executor.context
|
|
453
|
+
})),
|
|
454
|
+
fallbacks.map((fallback) => ({
|
|
455
|
+
module: fallback.address,
|
|
456
|
+
initData: fallback.context
|
|
457
|
+
})),
|
|
458
|
+
hooks.map((hook) => ({
|
|
459
|
+
module: hook.address,
|
|
460
|
+
initData: hook.context
|
|
461
|
+
})),
|
|
462
|
+
attesters,
|
|
463
|
+
attestersThreshold
|
|
464
|
+
]
|
|
465
|
+
}),
|
|
466
|
+
safe7579: safe4337ModuleAddress,
|
|
467
|
+
validators: validators
|
|
468
|
+
};
|
|
469
|
+
return initData;
|
|
470
|
+
};
|
|
471
|
+
const getInitializerCode = async ({ owner, safeModuleSetupAddress, safe4337ModuleAddress, multiSendAddress, safeSingletonAddress, erc7569LaunchpadAddress, setupTransactions = [], safeModules = [], validators = [], executors = [], fallbacks = [], hooks = [], attesters = [], attestersThreshold = 0 }) => {
|
|
472
|
+
if (erc7569LaunchpadAddress) {
|
|
473
|
+
const initData = get7579LaunchPadInitData({
|
|
474
|
+
safe4337ModuleAddress,
|
|
475
|
+
safeSingletonAddress,
|
|
476
|
+
erc7569LaunchpadAddress,
|
|
477
|
+
owner,
|
|
478
|
+
validators,
|
|
479
|
+
executors,
|
|
480
|
+
fallbacks,
|
|
481
|
+
hooks,
|
|
482
|
+
attesters,
|
|
483
|
+
attestersThreshold
|
|
484
|
+
});
|
|
485
|
+
const initHash = (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([
|
|
486
|
+
{
|
|
487
|
+
internalType: "address",
|
|
488
|
+
name: "singleton",
|
|
489
|
+
type: "address"
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
internalType: "address[]",
|
|
493
|
+
name: "owners",
|
|
494
|
+
type: "address[]"
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
internalType: "uint256",
|
|
498
|
+
name: "threshold",
|
|
499
|
+
type: "uint256"
|
|
500
|
+
},
|
|
108
501
|
{
|
|
109
|
-
|
|
502
|
+
internalType: "address",
|
|
503
|
+
name: "setupTo",
|
|
504
|
+
type: "address"
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
internalType: "bytes",
|
|
508
|
+
name: "setupData",
|
|
509
|
+
type: "bytes"
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
internalType: "contract ISafe7579",
|
|
513
|
+
name: "safe7579",
|
|
514
|
+
type: "address"
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
internalType: "struct ModuleInit[]",
|
|
518
|
+
name: "validators",
|
|
519
|
+
type: "tuple[]",
|
|
520
|
+
components: [
|
|
521
|
+
{
|
|
522
|
+
internalType: "address",
|
|
523
|
+
name: "module",
|
|
524
|
+
type: "address"
|
|
525
|
+
},
|
|
110
526
|
{
|
|
111
527
|
internalType: "bytes",
|
|
112
|
-
name: "
|
|
528
|
+
name: "initData",
|
|
113
529
|
type: "bytes"
|
|
114
530
|
}
|
|
115
|
-
]
|
|
116
|
-
name: "multiSend",
|
|
117
|
-
outputs: [],
|
|
118
|
-
stateMutability: "payable",
|
|
119
|
-
type: "function"
|
|
531
|
+
]
|
|
120
532
|
}
|
|
121
|
-
],
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
533
|
+
], [
|
|
534
|
+
initData.singleton,
|
|
535
|
+
initData.owners,
|
|
536
|
+
initData.threshold,
|
|
537
|
+
initData.setupTo,
|
|
538
|
+
initData.setupData,
|
|
539
|
+
initData.safe7579,
|
|
540
|
+
initData.validators.map((validator) => ({
|
|
541
|
+
module: validator.address,
|
|
542
|
+
initData: validator.context
|
|
543
|
+
}))
|
|
544
|
+
]));
|
|
545
|
+
return (0, viem_1.encodeFunctionData)({
|
|
546
|
+
abi: preValidationSetupAbi,
|
|
547
|
+
functionName: "preValidationSetup",
|
|
548
|
+
args: [initHash, viem_1.zeroAddress, "0x"]
|
|
549
|
+
});
|
|
550
|
+
}
|
|
127
551
|
const multiSendCallData = encodeMultiSend([
|
|
128
552
|
{
|
|
129
553
|
to: safeModuleSetupAddress,
|
|
130
554
|
data: (0, viem_1.encodeFunctionData)({
|
|
131
|
-
abi:
|
|
132
|
-
{
|
|
133
|
-
inputs: [
|
|
134
|
-
{
|
|
135
|
-
internalType: "address[]",
|
|
136
|
-
name: "modules",
|
|
137
|
-
type: "address[]"
|
|
138
|
-
}
|
|
139
|
-
],
|
|
140
|
-
name: "enableModules",
|
|
141
|
-
outputs: [],
|
|
142
|
-
stateMutability: "nonpayable",
|
|
143
|
-
type: "function"
|
|
144
|
-
}
|
|
145
|
-
],
|
|
555
|
+
abi: enableModulesAbi,
|
|
146
556
|
functionName: "enableModules",
|
|
147
557
|
args: [[safe4337ModuleAddress, ...safeModules]]
|
|
148
558
|
}),
|
|
@@ -152,56 +562,7 @@ const getInitializerCode = async ({ owner, safeModuleSetupAddress, safe4337Modul
|
|
|
152
562
|
...setupTransactions.map((tx) => ({ ...tx, operation: 0 }))
|
|
153
563
|
]);
|
|
154
564
|
return (0, viem_1.encodeFunctionData)({
|
|
155
|
-
abi:
|
|
156
|
-
{
|
|
157
|
-
inputs: [
|
|
158
|
-
{
|
|
159
|
-
internalType: "address[]",
|
|
160
|
-
name: "_owners",
|
|
161
|
-
type: "address[]"
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
internalType: "uint256",
|
|
165
|
-
name: "_threshold",
|
|
166
|
-
type: "uint256"
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
internalType: "address",
|
|
170
|
-
name: "to",
|
|
171
|
-
type: "address"
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
internalType: "bytes",
|
|
175
|
-
name: "data",
|
|
176
|
-
type: "bytes"
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
internalType: "address",
|
|
180
|
-
name: "fallbackHandler",
|
|
181
|
-
type: "address"
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
internalType: "address",
|
|
185
|
-
name: "paymentToken",
|
|
186
|
-
type: "address"
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
internalType: "uint256",
|
|
190
|
-
name: "payment",
|
|
191
|
-
type: "uint256"
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
internalType: "address payable",
|
|
195
|
-
name: "paymentReceiver",
|
|
196
|
-
type: "address"
|
|
197
|
-
}
|
|
198
|
-
],
|
|
199
|
-
name: "setup",
|
|
200
|
-
outputs: [],
|
|
201
|
-
stateMutability: "nonpayable",
|
|
202
|
-
type: "function"
|
|
203
|
-
}
|
|
204
|
-
],
|
|
565
|
+
abi: setupAbi,
|
|
205
566
|
functionName: "setup",
|
|
206
567
|
args: [
|
|
207
568
|
[owner],
|
|
@@ -230,83 +591,63 @@ function getPaymasterAndData(unpackedUserOperation) {
|
|
|
230
591
|
])
|
|
231
592
|
: "0x";
|
|
232
593
|
}
|
|
233
|
-
const getAccountInitCode = async ({ owner, safeModuleSetupAddress, safe4337ModuleAddress, safeSingletonAddress, multiSendAddress, saltNonce = BigInt(0), setupTransactions = [], safeModules = [] }) => {
|
|
234
|
-
if (!owner)
|
|
594
|
+
const getAccountInitCode = async ({ owner, safeModuleSetupAddress, safe4337ModuleAddress, safeSingletonAddress, erc7569LaunchpadAddress, multiSendAddress, saltNonce = BigInt(0), setupTransactions = [], safeModules = [], validators = [], executors = [], fallbacks = [], hooks = [], attesters = [], attestersThreshold = 0 }) => {
|
|
595
|
+
if (!owner) {
|
|
235
596
|
throw new Error("Owner account not found");
|
|
597
|
+
}
|
|
236
598
|
const initializer = await getInitializerCode({
|
|
237
599
|
owner,
|
|
238
600
|
safeModuleSetupAddress,
|
|
239
601
|
safe4337ModuleAddress,
|
|
240
602
|
multiSendAddress,
|
|
241
603
|
setupTransactions,
|
|
242
|
-
|
|
604
|
+
safeSingletonAddress,
|
|
605
|
+
safeModules,
|
|
606
|
+
erc7569LaunchpadAddress,
|
|
607
|
+
validators,
|
|
608
|
+
executors,
|
|
609
|
+
fallbacks,
|
|
610
|
+
hooks,
|
|
611
|
+
attesters,
|
|
612
|
+
attestersThreshold
|
|
243
613
|
});
|
|
244
614
|
const initCodeCallData = (0, viem_1.encodeFunctionData)({
|
|
245
|
-
abi:
|
|
246
|
-
{
|
|
247
|
-
inputs: [
|
|
248
|
-
{
|
|
249
|
-
internalType: "address",
|
|
250
|
-
name: "_singleton",
|
|
251
|
-
type: "address"
|
|
252
|
-
},
|
|
253
|
-
{
|
|
254
|
-
internalType: "bytes",
|
|
255
|
-
name: "initializer",
|
|
256
|
-
type: "bytes"
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
internalType: "uint256",
|
|
260
|
-
name: "saltNonce",
|
|
261
|
-
type: "uint256"
|
|
262
|
-
}
|
|
263
|
-
],
|
|
264
|
-
name: "createProxyWithNonce",
|
|
265
|
-
outputs: [
|
|
266
|
-
{
|
|
267
|
-
internalType: "contract SafeProxy",
|
|
268
|
-
name: "proxy",
|
|
269
|
-
type: "address"
|
|
270
|
-
}
|
|
271
|
-
],
|
|
272
|
-
stateMutability: "nonpayable",
|
|
273
|
-
type: "function"
|
|
274
|
-
}
|
|
275
|
-
],
|
|
615
|
+
abi: createProxyWithNonceAbi,
|
|
276
616
|
functionName: "createProxyWithNonce",
|
|
277
|
-
args: [
|
|
617
|
+
args: [
|
|
618
|
+
erc7569LaunchpadAddress ?? safeSingletonAddress,
|
|
619
|
+
initializer,
|
|
620
|
+
saltNonce
|
|
621
|
+
]
|
|
278
622
|
});
|
|
279
623
|
return initCodeCallData;
|
|
280
624
|
};
|
|
281
|
-
const getAccountAddress = async ({ client, owner, safeModuleSetupAddress, safe4337ModuleAddress, safeProxyFactoryAddress, safeSingletonAddress, multiSendAddress, setupTransactions = [], safeModules = [], saltNonce = BigInt(0) }) => {
|
|
625
|
+
const getAccountAddress = async ({ client, owner, safeModuleSetupAddress, safe4337ModuleAddress, safeProxyFactoryAddress, safeSingletonAddress, multiSendAddress, erc7569LaunchpadAddress, setupTransactions = [], safeModules = [], saltNonce = BigInt(0), validators = [], executors = [], fallbacks = [], hooks = [], attesters = [], attestersThreshold = 0 }) => {
|
|
282
626
|
const proxyCreationCode = await (0, actions_1.readContract)(client, {
|
|
283
|
-
abi:
|
|
284
|
-
{
|
|
285
|
-
inputs: [],
|
|
286
|
-
name: "proxyCreationCode",
|
|
287
|
-
outputs: [
|
|
288
|
-
{
|
|
289
|
-
internalType: "bytes",
|
|
290
|
-
name: "",
|
|
291
|
-
type: "bytes"
|
|
292
|
-
}
|
|
293
|
-
],
|
|
294
|
-
stateMutability: "pure",
|
|
295
|
-
type: "function"
|
|
296
|
-
}
|
|
297
|
-
],
|
|
627
|
+
abi: proxyCreationCodeAbi,
|
|
298
628
|
address: safeProxyFactoryAddress,
|
|
299
629
|
functionName: "proxyCreationCode"
|
|
300
630
|
});
|
|
301
|
-
const deploymentCode = (0, viem_1.encodePacked)(["bytes", "uint256"], [proxyCreationCode, (0, viem_1.hexToBigInt)(safeSingletonAddress)]);
|
|
302
631
|
const initializer = await getInitializerCode({
|
|
303
632
|
owner,
|
|
304
633
|
safeModuleSetupAddress,
|
|
305
634
|
safe4337ModuleAddress,
|
|
306
635
|
multiSendAddress,
|
|
307
636
|
setupTransactions,
|
|
308
|
-
|
|
637
|
+
safeSingletonAddress,
|
|
638
|
+
safeModules,
|
|
639
|
+
erc7569LaunchpadAddress,
|
|
640
|
+
validators,
|
|
641
|
+
executors,
|
|
642
|
+
fallbacks,
|
|
643
|
+
hooks,
|
|
644
|
+
attesters,
|
|
645
|
+
attestersThreshold
|
|
309
646
|
});
|
|
647
|
+
const deploymentCode = (0, viem_1.encodePacked)(["bytes", "uint256"], [
|
|
648
|
+
proxyCreationCode,
|
|
649
|
+
(0, viem_1.hexToBigInt)(erc7569LaunchpadAddress ?? safeSingletonAddress)
|
|
650
|
+
]);
|
|
310
651
|
const salt = (0, viem_1.keccak256)((0, viem_1.encodePacked)(["bytes32", "uint256"], [(0, viem_1.keccak256)((0, viem_1.encodePacked)(["bytes"], [initializer])), saltNonce]));
|
|
311
652
|
return (0, viem_1.getContractAddress)({
|
|
312
653
|
from: safeProxyFactoryAddress,
|
|
@@ -344,8 +685,38 @@ const getDefaultAddresses = (safeVersion, entryPointAddress, { addModuleLibAddre
|
|
|
344
685
|
multiSendCallOnlyAddress
|
|
345
686
|
};
|
|
346
687
|
};
|
|
347
|
-
|
|
688
|
+
function isErc7579Args(args) {
|
|
689
|
+
return args.erc7569LaunchpadAddress !== undefined;
|
|
690
|
+
}
|
|
691
|
+
async function signerToSafeSmartAccount(client, args) {
|
|
348
692
|
const chainId = client.chain?.id ?? (await (0, actions_1.getChainId)(client));
|
|
693
|
+
const { signer, address, safeVersion, entryPoint: entryPointAddress, safe4337ModuleAddress: _safe4337ModuleAddress, safeProxyFactoryAddress: _safeProxyFactoryAddress, safeSingletonAddress: _safeSingletonAddress, erc7569LaunchpadAddress, saltNonce = BigInt(0), validUntil = 0, validAfter = 0, nonceKey } = args;
|
|
694
|
+
let _safeModuleSetupAddress = undefined;
|
|
695
|
+
let _multiSendAddress = undefined;
|
|
696
|
+
let _multiSendCallOnlyAddress = undefined;
|
|
697
|
+
let safeModules = undefined;
|
|
698
|
+
let setupTransactions = [];
|
|
699
|
+
let validators = [];
|
|
700
|
+
let executors = [];
|
|
701
|
+
let fallbacks = [];
|
|
702
|
+
let hooks = [];
|
|
703
|
+
let attesters = [];
|
|
704
|
+
let attestersThreshold = 0;
|
|
705
|
+
if (!isErc7579Args(args)) {
|
|
706
|
+
_safeModuleSetupAddress = args.safeModuleSetupAddress;
|
|
707
|
+
_multiSendAddress = args.multiSendAddress;
|
|
708
|
+
_multiSendCallOnlyAddress = args.multiSendCallOnlyAddress;
|
|
709
|
+
safeModules = args.safeModules;
|
|
710
|
+
setupTransactions = args.setupTransactions ?? [];
|
|
711
|
+
}
|
|
712
|
+
if (isErc7579Args(args)) {
|
|
713
|
+
validators = args.validators ?? [];
|
|
714
|
+
executors = args.executors ?? [];
|
|
715
|
+
fallbacks = args.fallbacks ?? [];
|
|
716
|
+
hooks = args.hooks ?? [];
|
|
717
|
+
attesters = args.attesters ?? [];
|
|
718
|
+
attestersThreshold = args.attestersThreshold ?? 0;
|
|
719
|
+
}
|
|
349
720
|
const viemSigner = {
|
|
350
721
|
...signer,
|
|
351
722
|
signTransaction: (_, __) => {
|
|
@@ -369,15 +740,26 @@ async function signerToSafeSmartAccount(client, { signer, address, safeVersion,
|
|
|
369
740
|
safeProxyFactoryAddress,
|
|
370
741
|
safeSingletonAddress,
|
|
371
742
|
multiSendAddress,
|
|
743
|
+
erc7569LaunchpadAddress,
|
|
372
744
|
saltNonce,
|
|
373
745
|
setupTransactions,
|
|
374
|
-
safeModules
|
|
746
|
+
safeModules,
|
|
747
|
+
validators,
|
|
748
|
+
executors,
|
|
749
|
+
fallbacks,
|
|
750
|
+
hooks,
|
|
751
|
+
attesters,
|
|
752
|
+
attestersThreshold
|
|
375
753
|
}));
|
|
376
754
|
if (!accountAddress)
|
|
377
755
|
throw new Error("Account address not found");
|
|
378
756
|
let safeDeployed = await (0, isSmartAccountDeployed_1.isSmartAccountDeployed)(client, accountAddress);
|
|
379
757
|
const safeSmartAccount = (0, toSmartAccount_1.toSmartAccount)({
|
|
380
758
|
address: accountAddress,
|
|
759
|
+
client: client,
|
|
760
|
+
publicKey: accountAddress,
|
|
761
|
+
entryPoint: entryPointAddress,
|
|
762
|
+
source: "SafeSmartAccount",
|
|
381
763
|
async signMessage({ message }) {
|
|
382
764
|
const messageHash = (0, viem_1.hashTypedData)({
|
|
383
765
|
domain: {
|
|
@@ -418,14 +800,11 @@ async function signerToSafeSmartAccount(client, { signer, address, safeVersion,
|
|
|
418
800
|
}
|
|
419
801
|
}));
|
|
420
802
|
},
|
|
421
|
-
|
|
422
|
-
publicKey: accountAddress,
|
|
423
|
-
entryPoint: entryPointAddress,
|
|
424
|
-
source: "SafeSmartAccount",
|
|
425
|
-
async getNonce() {
|
|
803
|
+
async getNonce(key) {
|
|
426
804
|
return (0, getAccountNonce_1.getAccountNonce)(client, {
|
|
427
805
|
sender: accountAddress,
|
|
428
|
-
entryPoint: entryPointAddress
|
|
806
|
+
entryPoint: entryPointAddress,
|
|
807
|
+
key: key ?? nonceKey
|
|
429
808
|
});
|
|
430
809
|
},
|
|
431
810
|
async signUserOperation(userOperation) {
|
|
@@ -444,8 +823,10 @@ async function signerToSafeSmartAccount(client, { signer, address, safeVersion,
|
|
|
444
823
|
validUntil: validUntil,
|
|
445
824
|
entryPoint: entryPointAddress
|
|
446
825
|
};
|
|
826
|
+
let isDeployed = false;
|
|
447
827
|
if ((0, getEntryPointVersion_1.isUserOperationVersion06)(entryPointAddress, userOperation)) {
|
|
448
828
|
message.paymasterAndData = userOperation.paymasterAndData;
|
|
829
|
+
isDeployed = userOperation.initCode === "0x";
|
|
449
830
|
}
|
|
450
831
|
if ((0, getEntryPointVersion_1.isUserOperationVersion07)(entryPointAddress, userOperation)) {
|
|
451
832
|
if (userOperation.factory && userOperation.factoryData) {
|
|
@@ -456,6 +837,11 @@ async function signerToSafeSmartAccount(client, { signer, address, safeVersion,
|
|
|
456
837
|
}
|
|
457
838
|
message.paymasterAndData =
|
|
458
839
|
getPaymasterAndData(userOperation);
|
|
840
|
+
isDeployed = !userOperation.factory;
|
|
841
|
+
}
|
|
842
|
+
let verifyingContract = safe4337ModuleAddress;
|
|
843
|
+
if (erc7569LaunchpadAddress && !isDeployed) {
|
|
844
|
+
verifyingContract = userOperation.sender;
|
|
459
845
|
}
|
|
460
846
|
const signatures = [
|
|
461
847
|
{
|
|
@@ -463,8 +849,8 @@ async function signerToSafeSmartAccount(client, { signer, address, safeVersion,
|
|
|
463
849
|
data: await (0, actions_1.signTypedData)(client, {
|
|
464
850
|
account: viemSigner,
|
|
465
851
|
domain: {
|
|
466
|
-
chainId
|
|
467
|
-
verifyingContract
|
|
852
|
+
chainId,
|
|
853
|
+
verifyingContract
|
|
468
854
|
},
|
|
469
855
|
types: (0, getEntryPointVersion_1.getEntryPointVersion)(entryPointAddress) ===
|
|
470
856
|
"v0.6"
|
|
@@ -512,20 +898,80 @@ async function signerToSafeSmartAccount(client, { signer, address, safeVersion,
|
|
|
512
898
|
safe4337ModuleAddress,
|
|
513
899
|
safeSingletonAddress,
|
|
514
900
|
multiSendAddress,
|
|
901
|
+
erc7569LaunchpadAddress,
|
|
515
902
|
saltNonce,
|
|
516
903
|
setupTransactions,
|
|
517
|
-
safeModules
|
|
904
|
+
safeModules,
|
|
905
|
+
validators,
|
|
906
|
+
executors,
|
|
907
|
+
fallbacks,
|
|
908
|
+
hooks,
|
|
909
|
+
attesters,
|
|
910
|
+
attestersThreshold
|
|
518
911
|
});
|
|
519
912
|
},
|
|
520
913
|
async encodeDeployCallData(_) {
|
|
521
914
|
throw new Error("Safe account doesn't support account deployment");
|
|
522
915
|
},
|
|
523
916
|
async encodeCallData(args) {
|
|
917
|
+
const isArray = Array.isArray(args);
|
|
918
|
+
if (erc7569LaunchpadAddress) {
|
|
919
|
+
safeDeployed =
|
|
920
|
+
safeDeployed ||
|
|
921
|
+
(await (0, isSmartAccountDeployed_1.isSmartAccountDeployed)(client, accountAddress));
|
|
922
|
+
if (!safeDeployed) {
|
|
923
|
+
const initData = get7579LaunchPadInitData({
|
|
924
|
+
safe4337ModuleAddress,
|
|
925
|
+
safeSingletonAddress,
|
|
926
|
+
erc7569LaunchpadAddress,
|
|
927
|
+
owner: viemSigner.address,
|
|
928
|
+
validators,
|
|
929
|
+
executors,
|
|
930
|
+
fallbacks,
|
|
931
|
+
hooks,
|
|
932
|
+
attesters,
|
|
933
|
+
attestersThreshold
|
|
934
|
+
});
|
|
935
|
+
return (0, viem_1.encodeFunctionData)({
|
|
936
|
+
abi: setupSafeAbi,
|
|
937
|
+
functionName: "setupSafe",
|
|
938
|
+
args: [
|
|
939
|
+
{
|
|
940
|
+
...initData,
|
|
941
|
+
validators: initData.validators.map((validator) => ({
|
|
942
|
+
module: validator.address,
|
|
943
|
+
initData: validator.context
|
|
944
|
+
})),
|
|
945
|
+
callData: (0, encode7579CallData_1.encode7579CallData)({
|
|
946
|
+
mode: {
|
|
947
|
+
type: isArray
|
|
948
|
+
? "batchcall"
|
|
949
|
+
: "call",
|
|
950
|
+
revertOnError: false,
|
|
951
|
+
selector: "0x",
|
|
952
|
+
context: "0x"
|
|
953
|
+
},
|
|
954
|
+
callData: args
|
|
955
|
+
})
|
|
956
|
+
}
|
|
957
|
+
]
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
return (0, encode7579CallData_1.encode7579CallData)({
|
|
961
|
+
mode: {
|
|
962
|
+
type: isArray ? "batchcall" : "call",
|
|
963
|
+
revertOnError: false,
|
|
964
|
+
selector: "0x",
|
|
965
|
+
context: "0x"
|
|
966
|
+
},
|
|
967
|
+
callData: args
|
|
968
|
+
});
|
|
969
|
+
}
|
|
524
970
|
let to;
|
|
525
971
|
let value;
|
|
526
972
|
let data;
|
|
527
973
|
let operationType = 0;
|
|
528
|
-
if (
|
|
974
|
+
if (isArray) {
|
|
529
975
|
const argsArray = args;
|
|
530
976
|
to = multiSendCallOnlyAddress;
|
|
531
977
|
value = BigInt(0);
|
|
@@ -539,36 +985,7 @@ async function signerToSafeSmartAccount(client, { signer, address, safeVersion,
|
|
|
539
985
|
value = singleTransaction.value;
|
|
540
986
|
}
|
|
541
987
|
return (0, viem_1.encodeFunctionData)({
|
|
542
|
-
abi:
|
|
543
|
-
{
|
|
544
|
-
inputs: [
|
|
545
|
-
{
|
|
546
|
-
internalType: "address",
|
|
547
|
-
name: "to",
|
|
548
|
-
type: "address"
|
|
549
|
-
},
|
|
550
|
-
{
|
|
551
|
-
internalType: "uint256",
|
|
552
|
-
name: "value",
|
|
553
|
-
type: "uint256"
|
|
554
|
-
},
|
|
555
|
-
{
|
|
556
|
-
internalType: "bytes",
|
|
557
|
-
name: "data",
|
|
558
|
-
type: "bytes"
|
|
559
|
-
},
|
|
560
|
-
{
|
|
561
|
-
internalType: "uint8",
|
|
562
|
-
name: "operation",
|
|
563
|
-
type: "uint8"
|
|
564
|
-
}
|
|
565
|
-
],
|
|
566
|
-
name: "executeUserOpWithErrorString",
|
|
567
|
-
outputs: [],
|
|
568
|
-
stateMutability: "nonpayable",
|
|
569
|
-
type: "function"
|
|
570
|
-
}
|
|
571
|
-
],
|
|
988
|
+
abi: executeUserOpWithErrorStringAbi,
|
|
572
989
|
functionName: "executeUserOpWithErrorString",
|
|
573
990
|
args: [to, value, data, operationType]
|
|
574
991
|
});
|