permissionless 0.0.35 → 0.1.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/CHANGELOG.md +14 -0
- package/_cjs/accounts/biconomy/privateKeyToBiconomySmartAccount.js.map +1 -1
- package/_cjs/accounts/biconomy/signerToBiconomySmartAccount.js +32 -15
- package/_cjs/accounts/biconomy/signerToBiconomySmartAccount.js.map +1 -1
- package/_cjs/accounts/kernel/signerToEcdsaKernelSmartAccount.js +38 -20
- package/_cjs/accounts/kernel/signerToEcdsaKernelSmartAccount.js.map +1 -1
- package/_cjs/accounts/safe/privateKeyToSafeSmartAccount.js.map +1 -1
- package/_cjs/accounts/safe/signerToSafeSmartAccount.js +42 -11
- package/_cjs/accounts/safe/signerToSafeSmartAccount.js.map +1 -1
- package/_cjs/accounts/simple/privateKeyToSimpleSmartAccount.js.map +1 -1
- package/_cjs/accounts/simple/signerToSimpleSmartAccount.js +104 -44
- package/_cjs/accounts/simple/signerToSimpleSmartAccount.js.map +1 -1
- package/_cjs/accounts/types.js.map +1 -1
- package/_cjs/actions/bundler/chainId.js.map +1 -1
- package/_cjs/actions/bundler/estimateUserOperationGas.js +20 -3
- package/_cjs/actions/bundler/estimateUserOperationGas.js.map +1 -1
- package/_cjs/actions/bundler/getUserOperationByHash.js +28 -11
- package/_cjs/actions/bundler/getUserOperationByHash.js.map +1 -1
- package/_cjs/actions/bundler/getUserOperationReceipt.js.map +1 -1
- package/_cjs/actions/bundler/sendUserOperation.js.map +1 -1
- package/_cjs/actions/bundler/supportedEntryPoints.js.map +1 -1
- package/_cjs/actions/pimlico/getUserOperationGasPrice.js +7 -7
- package/_cjs/actions/pimlico/getUserOperationGasPrice.js.map +1 -1
- package/_cjs/actions/pimlico/sponsorUserOperation.js +19 -7
- package/_cjs/actions/pimlico/sponsorUserOperation.js.map +1 -1
- package/_cjs/actions/pimlico/validateSponsorshipPolicies.js.map +1 -1
- package/_cjs/actions/public/getAccountNonce.js.map +1 -1
- package/_cjs/actions/public/getSenderAddress.js +5 -2
- package/_cjs/actions/public/getSenderAddress.js.map +1 -1
- package/_cjs/actions/smartAccount/deployContract.js +3 -4
- package/_cjs/actions/smartAccount/deployContract.js.map +1 -1
- package/_cjs/actions/smartAccount/prepareUserOperationRequest.js +142 -19
- package/_cjs/actions/smartAccount/prepareUserOperationRequest.js.map +1 -1
- package/_cjs/actions/smartAccount/sendTransaction.js +3 -4
- package/_cjs/actions/smartAccount/sendTransaction.js.map +1 -1
- package/_cjs/actions/smartAccount/sendTransactions.js +3 -4
- package/_cjs/actions/smartAccount/sendTransactions.js.map +1 -1
- package/_cjs/actions/smartAccount/sendUserOperation.js +1 -1
- package/_cjs/actions/smartAccount/sendUserOperation.js.map +1 -1
- package/_cjs/actions/smartAccount/signMessage.js.map +1 -1
- package/_cjs/actions/smartAccount/signTypedData.js.map +1 -1
- package/_cjs/actions/smartAccount/writeContract.js.map +1 -1
- package/_cjs/actions/stackup/accounts.js +2 -2
- package/_cjs/actions/stackup/accounts.js.map +1 -1
- package/_cjs/actions/stackup/sponsorUserOperation.js +20 -12
- package/_cjs/actions/stackup/sponsorUserOperation.js.map +1 -1
- package/_cjs/clients/createBundlerClient.js +1 -1
- package/_cjs/clients/createBundlerClient.js.map +1 -1
- package/_cjs/clients/createSmartAccountClient.js +3 -3
- package/_cjs/clients/createSmartAccountClient.js.map +1 -1
- package/_cjs/clients/decorators/bundler.js +6 -3
- package/_cjs/clients/decorators/bundler.js.map +1 -1
- package/_cjs/clients/decorators/pimlico.js +6 -3
- package/_cjs/clients/decorators/pimlico.js.map +1 -1
- package/_cjs/clients/decorators/smartAccount.js +7 -7
- package/_cjs/clients/decorators/smartAccount.js.map +1 -1
- package/_cjs/clients/decorators/stackup.js.map +1 -1
- package/_cjs/clients/pimlico.js +4 -2
- package/_cjs/clients/pimlico.js.map +1 -1
- package/_cjs/clients/stackup.js +3 -1
- package/_cjs/clients/stackup.js.map +1 -1
- package/_cjs/errors/estimateUserOperationGas.js.map +1 -1
- package/_cjs/errors/sendUserOperation.js.map +1 -1
- package/_cjs/types/entrypoint.js +3 -0
- package/_cjs/types/entrypoint.js.map +1 -0
- package/_cjs/utils/errors/getBundlerError.js.map +1 -1
- package/_cjs/utils/errors/getEstimateUserOperationGasError.js.map +1 -1
- package/_cjs/utils/errors/getSendUserOperationError.js.map +1 -1
- package/_cjs/utils/getEntryPointVersion.js +8 -0
- package/_cjs/utils/getEntryPointVersion.js.map +1 -0
- package/_cjs/utils/getRequiredPrefund.js +19 -6
- package/_cjs/utils/getRequiredPrefund.js.map +1 -1
- package/_cjs/utils/getUserOperationHash.js +81 -17
- package/_cjs/utils/getUserOperationHash.js.map +1 -1
- package/_cjs/utils/index.js +5 -1
- package/_cjs/utils/index.js.map +1 -1
- package/_cjs/utils/providerToSmartAccountSigner.js +1 -1
- package/_cjs/utils/providerToSmartAccountSigner.js.map +1 -1
- package/_cjs/utils/signUserOperationHashWithECDSA.js +2 -2
- package/_cjs/utils/signUserOperationHashWithECDSA.js.map +1 -1
- package/_esm/accounts/biconomy/privateKeyToBiconomySmartAccount.js.map +1 -1
- package/_esm/accounts/biconomy/signerToBiconomySmartAccount.js +32 -15
- package/_esm/accounts/biconomy/signerToBiconomySmartAccount.js.map +1 -1
- package/_esm/accounts/kernel/signerToEcdsaKernelSmartAccount.js +38 -21
- package/_esm/accounts/kernel/signerToEcdsaKernelSmartAccount.js.map +1 -1
- package/_esm/accounts/safe/privateKeyToSafeSmartAccount.js.map +1 -1
- package/_esm/accounts/safe/signerToSafeSmartAccount.js +42 -11
- package/_esm/accounts/safe/signerToSafeSmartAccount.js.map +1 -1
- package/_esm/accounts/simple/privateKeyToSimpleSmartAccount.js.map +1 -1
- package/_esm/accounts/simple/signerToSimpleSmartAccount.js +105 -44
- package/_esm/accounts/simple/signerToSimpleSmartAccount.js.map +1 -1
- package/_esm/accounts/types.js +0 -1
- package/_esm/accounts/types.js.map +1 -1
- package/_esm/actions/bundler/chainId.js.map +1 -1
- package/_esm/actions/bundler/estimateUserOperationGas.js +20 -3
- package/_esm/actions/bundler/estimateUserOperationGas.js.map +1 -1
- package/_esm/actions/bundler/getUserOperationByHash.js +28 -11
- package/_esm/actions/bundler/getUserOperationByHash.js.map +1 -1
- package/_esm/actions/bundler/getUserOperationReceipt.js.map +1 -1
- package/_esm/actions/bundler/sendUserOperation.js.map +1 -1
- package/_esm/actions/bundler/supportedEntryPoints.js.map +1 -1
- package/_esm/actions/pimlico/getUserOperationGasPrice.js +7 -7
- package/_esm/actions/pimlico/getUserOperationGasPrice.js.map +1 -1
- package/_esm/actions/pimlico/sponsorUserOperation.js +19 -7
- package/_esm/actions/pimlico/sponsorUserOperation.js.map +1 -1
- package/_esm/actions/pimlico/validateSponsorshipPolicies.js.map +1 -1
- package/_esm/actions/public/getAccountNonce.js.map +1 -1
- package/_esm/actions/public/getSenderAddress.js +6 -3
- package/_esm/actions/public/getSenderAddress.js.map +1 -1
- package/_esm/actions/smartAccount/deployContract.js +3 -4
- package/_esm/actions/smartAccount/deployContract.js.map +1 -1
- package/_esm/actions/smartAccount/prepareUserOperationRequest.js +142 -19
- package/_esm/actions/smartAccount/prepareUserOperationRequest.js.map +1 -1
- package/_esm/actions/smartAccount/sendTransaction.js +3 -4
- package/_esm/actions/smartAccount/sendTransaction.js.map +1 -1
- package/_esm/actions/smartAccount/sendTransactions.js +3 -4
- package/_esm/actions/smartAccount/sendTransactions.js.map +1 -1
- package/_esm/actions/smartAccount/sendUserOperation.js +1 -1
- package/_esm/actions/smartAccount/sendUserOperation.js.map +1 -1
- package/_esm/actions/smartAccount/signMessage.js.map +1 -1
- package/_esm/actions/smartAccount/signTypedData.js.map +1 -1
- package/_esm/actions/smartAccount/writeContract.js.map +1 -1
- package/_esm/actions/stackup/accounts.js +2 -2
- package/_esm/actions/stackup/accounts.js.map +1 -1
- package/_esm/actions/stackup/sponsorUserOperation.js +20 -12
- package/_esm/actions/stackup/sponsorUserOperation.js.map +1 -1
- package/_esm/clients/createBundlerClient.js +1 -1
- package/_esm/clients/createBundlerClient.js.map +1 -1
- package/_esm/clients/createSmartAccountClient.js +22 -3
- package/_esm/clients/createSmartAccountClient.js.map +1 -1
- package/_esm/clients/decorators/bundler.js +6 -3
- package/_esm/clients/decorators/bundler.js.map +1 -1
- package/_esm/clients/decorators/pimlico.js +6 -3
- package/_esm/clients/decorators/pimlico.js.map +1 -1
- package/_esm/clients/decorators/smartAccount.js +7 -7
- package/_esm/clients/decorators/smartAccount.js.map +1 -1
- package/_esm/clients/decorators/stackup.js.map +1 -1
- package/_esm/clients/pimlico.js +4 -2
- package/_esm/clients/pimlico.js.map +1 -1
- package/_esm/clients/stackup.js +3 -1
- package/_esm/clients/stackup.js.map +1 -1
- package/_esm/errors/estimateUserOperationGas.js.map +1 -1
- package/_esm/errors/sendUserOperation.js.map +1 -1
- package/_esm/types/entrypoint.js +2 -0
- package/_esm/types/entrypoint.js.map +1 -0
- package/_esm/utils/errors/getBundlerError.js.map +1 -1
- package/_esm/utils/errors/getEstimateUserOperationGasError.js.map +1 -1
- package/_esm/utils/errors/getSendUserOperationError.js.map +1 -1
- package/_esm/utils/getEntryPointVersion.js +4 -0
- package/_esm/utils/getEntryPointVersion.js.map +1 -0
- package/_esm/utils/getRequiredPrefund.js +19 -6
- package/_esm/utils/getRequiredPrefund.js.map +1 -1
- package/_esm/utils/getUserOperationHash.js +82 -18
- package/_esm/utils/getUserOperationHash.js.map +1 -1
- package/_esm/utils/index.js +2 -1
- package/_esm/utils/index.js.map +1 -1
- package/_esm/utils/providerToSmartAccountSigner.js +1 -1
- package/_esm/utils/providerToSmartAccountSigner.js.map +1 -1
- package/_esm/utils/signUserOperationHashWithECDSA.js +2 -3
- package/_esm/utils/signUserOperationHashWithECDSA.js.map +1 -1
- package/_types/accounts/biconomy/privateKeyToBiconomySmartAccount.d.ts +4 -4
- package/_types/accounts/biconomy/privateKeyToBiconomySmartAccount.d.ts.map +1 -1
- package/_types/accounts/biconomy/signerToBiconomySmartAccount.d.ts +5 -4
- package/_types/accounts/biconomy/signerToBiconomySmartAccount.d.ts.map +1 -1
- package/_types/accounts/kernel/signerToEcdsaKernelSmartAccount.d.ts +5 -4
- package/_types/accounts/kernel/signerToEcdsaKernelSmartAccount.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 +6 -5
- package/_types/accounts/safe/signerToSafeSmartAccount.d.ts.map +1 -1
- package/_types/accounts/simple/privateKeyToSimpleSmartAccount.d.ts +4 -4
- package/_types/accounts/simple/privateKeyToSimpleSmartAccount.d.ts.map +1 -1
- package/_types/accounts/simple/signerToSimpleSmartAccount.d.ts +5 -4
- package/_types/accounts/simple/signerToSimpleSmartAccount.d.ts.map +1 -1
- package/_types/accounts/types.d.ts +8 -5
- package/_types/accounts/types.d.ts.map +1 -1
- package/_types/actions/bundler/chainId.d.ts +2 -1
- package/_types/actions/bundler/chainId.d.ts.map +1 -1
- package/_types/actions/bundler/estimateUserOperationGas.d.ts +14 -7
- package/_types/actions/bundler/estimateUserOperationGas.d.ts.map +1 -1
- package/_types/actions/bundler/getUserOperationByHash.d.ts +10 -3
- package/_types/actions/bundler/getUserOperationByHash.d.ts.map +1 -1
- package/_types/actions/bundler/getUserOperationReceipt.d.ts +2 -1
- package/_types/actions/bundler/getUserOperationReceipt.d.ts.map +1 -1
- package/_types/actions/bundler/sendUserOperation.d.ts +6 -5
- package/_types/actions/bundler/sendUserOperation.d.ts.map +1 -1
- package/_types/actions/bundler/supportedEntryPoints.d.ts +3 -2
- package/_types/actions/bundler/supportedEntryPoints.d.ts.map +1 -1
- package/_types/actions/pimlico/getUserOperationGasPrice.d.ts.map +1 -1
- package/_types/actions/pimlico/sponsorUserOperation.d.ts +47 -6
- package/_types/actions/pimlico/sponsorUserOperation.d.ts.map +1 -1
- package/_types/actions/pimlico/validateSponsorshipPolicies.d.ts +10 -5
- package/_types/actions/pimlico/validateSponsorshipPolicies.d.ts.map +1 -1
- package/_types/actions/public/getAccountNonce.d.ts +2 -1
- package/_types/actions/public/getAccountNonce.d.ts.map +1 -1
- package/_types/actions/public/getSenderAddress.d.ts +11 -3
- package/_types/actions/public/getSenderAddress.d.ts.map +1 -1
- package/_types/actions/smartAccount/deployContract.d.ts +4 -3
- package/_types/actions/smartAccount/deployContract.d.ts.map +1 -1
- package/_types/actions/smartAccount/prepareUserOperationRequest.d.ts +21 -11
- package/_types/actions/smartAccount/prepareUserOperationRequest.d.ts.map +1 -1
- package/_types/actions/smartAccount/sendTransaction.d.ts +4 -3
- package/_types/actions/smartAccount/sendTransaction.d.ts.map +1 -1
- package/_types/actions/smartAccount/sendTransactions.d.ts +5 -4
- package/_types/actions/smartAccount/sendTransactions.d.ts.map +1 -1
- package/_types/actions/smartAccount/sendUserOperation.d.ts +6 -5
- package/_types/actions/smartAccount/sendUserOperation.d.ts.map +1 -1
- package/_types/actions/smartAccount/signMessage.d.ts +2 -1
- package/_types/actions/smartAccount/signMessage.d.ts.map +1 -1
- package/_types/actions/smartAccount/signTypedData.d.ts +3 -2
- package/_types/actions/smartAccount/signTypedData.d.ts.map +1 -1
- package/_types/actions/smartAccount/writeContract.d.ts +4 -3
- package/_types/actions/smartAccount/writeContract.d.ts.map +1 -1
- package/_types/actions/smartAccount.d.ts +2 -2
- package/_types/actions/smartAccount.d.ts.map +1 -1
- package/_types/actions/stackup/accounts.d.ts +4 -3
- package/_types/actions/stackup/accounts.d.ts.map +1 -1
- package/_types/actions/stackup/sponsorUserOperation.d.ts +6 -6
- package/_types/actions/stackup/sponsorUserOperation.d.ts.map +1 -1
- package/_types/clients/createBundlerClient.d.ts +6 -3
- package/_types/clients/createBundlerClient.d.ts.map +1 -1
- package/_types/clients/createSmartAccountClient.d.ts +9 -5
- package/_types/clients/createSmartAccountClient.d.ts.map +1 -1
- package/_types/clients/decorators/bundler.d.ts +7 -7
- package/_types/clients/decorators/bundler.d.ts.map +1 -1
- package/_types/clients/decorators/pimlico.d.ts +6 -5
- package/_types/clients/decorators/pimlico.d.ts.map +1 -1
- package/_types/clients/decorators/smartAccount.d.ts +12 -12
- package/_types/clients/decorators/smartAccount.d.ts.map +1 -1
- package/_types/clients/decorators/stackup.d.ts +5 -4
- package/_types/clients/decorators/stackup.d.ts.map +1 -1
- package/_types/clients/pimlico.d.ts +11 -6
- package/_types/clients/pimlico.d.ts.map +1 -1
- package/_types/clients/stackup.d.ts +6 -3
- package/_types/clients/stackup.d.ts.map +1 -1
- package/_types/errors/estimateUserOperationGas.d.ts +4 -3
- package/_types/errors/estimateUserOperationGas.d.ts.map +1 -1
- package/_types/errors/sendUserOperation.d.ts +4 -3
- package/_types/errors/sendUserOperation.d.ts.map +1 -1
- package/_types/types/bundler.d.ts +16 -21
- package/_types/types/bundler.d.ts.map +1 -1
- package/_types/types/entrypoint.d.ts +6 -0
- package/_types/types/entrypoint.d.ts.map +1 -0
- package/_types/types/index.d.ts +6 -4
- package/_types/types/index.d.ts.map +1 -1
- package/_types/types/pimlico.d.ts +20 -6
- package/_types/types/pimlico.d.ts.map +1 -1
- package/_types/types/stackup.d.ts +18 -4
- package/_types/types/stackup.d.ts.map +1 -1
- package/_types/types/userOperation.d.ts +51 -2
- package/_types/types/userOperation.d.ts.map +1 -1
- package/_types/utils/errors/getBundlerError.d.ts +4 -4
- package/_types/utils/errors/getBundlerError.d.ts.map +1 -1
- package/_types/utils/errors/getEstimateUserOperationGasError.d.ts +3 -2
- package/_types/utils/errors/getEstimateUserOperationGasError.d.ts.map +1 -1
- package/_types/utils/errors/getSendUserOperationError.d.ts +2 -1
- package/_types/utils/errors/getSendUserOperationError.d.ts.map +1 -1
- package/_types/utils/getEntryPointVersion.d.ts +6 -0
- package/_types/utils/getEntryPointVersion.d.ts.map +1 -0
- package/_types/utils/getRequiredPrefund.d.ts +5 -4
- package/_types/utils/getRequiredPrefund.d.ts.map +1 -1
- package/_types/utils/getUserOperationHash.d.ts +6 -5
- package/_types/utils/getUserOperationHash.d.ts.map +1 -1
- package/_types/utils/index.d.ts +2 -1
- package/_types/utils/index.d.ts.map +1 -1
- package/_types/utils/providerToSmartAccountSigner.d.ts +4 -1
- package/_types/utils/providerToSmartAccountSigner.d.ts.map +1 -1
- package/_types/utils/signUserOperationHashWithECDSA.d.ts +6 -6
- package/_types/utils/signUserOperationHashWithECDSA.d.ts.map +1 -1
- package/accounts/biconomy/privateKeyToBiconomySmartAccount.ts +17 -6
- package/accounts/biconomy/signerToBiconomySmartAccount.ts +50 -21
- package/accounts/kernel/signerToEcdsaKernelSmartAccount.ts +64 -30
- package/accounts/safe/privateKeyToSafeSmartAccount.ts +8 -5
- package/accounts/safe/signerToSafeSmartAccount.ts +57 -17
- package/accounts/simple/privateKeyToSimpleSmartAccount.ts +25 -7
- package/accounts/simple/signerToSimpleSmartAccount.ts +127 -56
- package/accounts/types.ts +12 -4
- package/actions/bundler/chainId.ts +3 -1
- package/actions/bundler/estimateUserOperationGas.ts +77 -22
- package/actions/bundler/getUserOperationByHash.ts +44 -15
- package/actions/bundler/getUserOperationReceipt.ts +3 -1
- package/actions/bundler/sendUserOperation.ts +13 -17
- package/actions/bundler/supportedEntryPoints.ts +5 -3
- package/actions/pimlico/getUserOperationGasPrice.ts +7 -9
- package/actions/pimlico/sponsorUserOperation.ts +97 -23
- package/actions/pimlico/validateSponsorshipPolicies.ts +18 -7
- package/actions/public/getAccountNonce.ts +2 -1
- package/actions/public/getSenderAddress.ts +30 -5
- package/actions/smartAccount/deployContract.ts +14 -10
- package/actions/smartAccount/prepareUserOperationRequest.ts +339 -49
- package/actions/smartAccount/sendTransaction.ts +20 -11
- package/actions/smartAccount/sendTransactions.ts +17 -11
- package/actions/smartAccount/sendUserOperation.ts +56 -23
- package/actions/smartAccount/signMessage.ts +3 -1
- package/actions/smartAccount/signTypedData.ts +3 -1
- package/actions/smartAccount/writeContract.ts +12 -5
- package/actions/smartAccount.ts +2 -2
- package/actions/stackup/accounts.ts +7 -6
- package/actions/stackup/sponsorUserOperation.ts +85 -31
- package/clients/createBundlerClient.ts +11 -6
- package/clients/createSmartAccountClient.ts +34 -20
- package/clients/decorators/bundler.ts +51 -27
- package/clients/decorators/pimlico.ts +43 -17
- package/clients/decorators/smartAccount.ts +115 -37
- package/clients/decorators/stackup.ts +14 -10
- package/clients/pimlico.ts +22 -13
- package/clients/stackup.ts +13 -7
- package/errors/estimateUserOperationGas.ts +7 -4
- package/errors/sendUserOperation.ts +9 -5
- package/package.json +1 -1
- package/types/bundler.ts +40 -28
- package/types/entrypoint.ts +13 -0
- package/types/index.ts +15 -5
- package/types/pimlico.ts +43 -17
- package/types/stackup.ts +39 -15
- package/types/userOperation.ts +82 -26
- package/utils/errors/getBundlerError.ts +10 -6
- package/utils/errors/getEstimateUserOperationGasError.ts +13 -10
- package/utils/errors/getSendUserOperationError.ts +4 -3
- package/utils/getEntryPointVersion.ts +15 -0
- package/utils/getRequiredPrefund.ts +35 -11
- package/utils/getUserOperationHash.ts +113 -23
- package/utils/index.ts +9 -1
- package/utils/providerToSmartAccountSigner.ts +6 -3
- package/utils/signUserOperationHashWithECDSA.ts +13 -7
|
@@ -20,6 +20,8 @@ import { toAccount } from "viem/accounts"
|
|
|
20
20
|
import { getChainId, signMessage, signTypedData } from "viem/actions"
|
|
21
21
|
import { getAccountNonce } from "../../actions/public/getAccountNonce"
|
|
22
22
|
import type { Prettify } from "../../types"
|
|
23
|
+
import type { ENTRYPOINT_ADDRESS_V06_TYPE } from "../../types/entrypoint"
|
|
24
|
+
import { getEntryPointVersion } from "../../utils"
|
|
23
25
|
import { getUserOperationHash } from "../../utils/getUserOperationHash"
|
|
24
26
|
import { isSmartAccountDeployed } from "../../utils/isSmartAccountDeployed"
|
|
25
27
|
import {
|
|
@@ -31,12 +33,12 @@ import {
|
|
|
31
33
|
BiconomyExecuteAbi,
|
|
32
34
|
BiconomyInitAbi
|
|
33
35
|
} from "./abi/BiconomySmartAccountAbi"
|
|
34
|
-
// import Abis
|
|
35
36
|
|
|
36
37
|
export type BiconomySmartAccount<
|
|
38
|
+
entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE,
|
|
37
39
|
transport extends Transport = Transport,
|
|
38
40
|
chain extends Chain | undefined = Chain | undefined
|
|
39
|
-
> = SmartAccount<"biconomySmartAccount", transport, chain>
|
|
41
|
+
> = SmartAccount<entryPoint, "biconomySmartAccount", transport, chain>
|
|
40
42
|
|
|
41
43
|
/**
|
|
42
44
|
* The account creation ABI for Biconomy Smart Account (from the biconomy SmartAccountFactory)
|
|
@@ -104,12 +106,10 @@ const BICONOMY_PROXY_CREATION_CODE =
|
|
|
104
106
|
const getAccountInitCode = async ({
|
|
105
107
|
owner,
|
|
106
108
|
index,
|
|
107
|
-
factoryAddress,
|
|
108
109
|
ecdsaModuleAddress
|
|
109
110
|
}: {
|
|
110
111
|
owner: Address
|
|
111
112
|
index: bigint
|
|
112
|
-
factoryAddress: Address
|
|
113
113
|
ecdsaModuleAddress: Address
|
|
114
114
|
}): Promise<Hex> => {
|
|
115
115
|
if (!owner) throw new Error("Owner account not found")
|
|
@@ -122,14 +122,11 @@ const getAccountInitCode = async ({
|
|
|
122
122
|
})
|
|
123
123
|
|
|
124
124
|
// Build the account init code
|
|
125
|
-
return
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
args: [ecdsaModuleAddress, ecdsaOwnershipInitData, index]
|
|
131
|
-
}) as Hex
|
|
132
|
-
])
|
|
125
|
+
return encodeFunctionData({
|
|
126
|
+
abi: createAccountAbi,
|
|
127
|
+
functionName: "deployCounterFactualAccount",
|
|
128
|
+
args: [ecdsaModuleAddress, ecdsaOwnershipInitData, index]
|
|
129
|
+
})
|
|
133
130
|
}
|
|
134
131
|
|
|
135
132
|
const getAccountAddress = async ({
|
|
@@ -186,11 +183,12 @@ const getAccountAddress = async ({
|
|
|
186
183
|
}
|
|
187
184
|
|
|
188
185
|
export type SignerToBiconomySmartAccountParameters<
|
|
186
|
+
entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE,
|
|
189
187
|
TSource extends string = "custom",
|
|
190
188
|
TAddress extends Address = Address
|
|
191
189
|
> = Prettify<{
|
|
192
190
|
signer: SmartAccountSigner<TSource, TAddress>
|
|
193
|
-
entryPoint:
|
|
191
|
+
entryPoint: entryPoint
|
|
194
192
|
address?: Address
|
|
195
193
|
index?: bigint
|
|
196
194
|
factoryAddress?: Address
|
|
@@ -210,6 +208,7 @@ export type SignerToBiconomySmartAccountParameters<
|
|
|
210
208
|
* @param ecdsaModuleAddress
|
|
211
209
|
*/
|
|
212
210
|
export async function signerToBiconomySmartAccount<
|
|
211
|
+
entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE,
|
|
213
212
|
TTransport extends Transport = Transport,
|
|
214
213
|
TChain extends Chain | undefined = Chain | undefined,
|
|
215
214
|
TSource extends string = "custom",
|
|
@@ -219,14 +218,20 @@ export async function signerToBiconomySmartAccount<
|
|
|
219
218
|
{
|
|
220
219
|
signer,
|
|
221
220
|
address,
|
|
222
|
-
entryPoint,
|
|
221
|
+
entryPoint: entryPointAddress,
|
|
223
222
|
index = 0n,
|
|
224
223
|
factoryAddress = BICONOMY_ADDRESSES.FACTORY_ADDRESS,
|
|
225
224
|
accountLogicAddress = BICONOMY_ADDRESSES.ACCOUNT_V2_0_LOGIC,
|
|
226
225
|
fallbackHandlerAddress = BICONOMY_ADDRESSES.DEFAULT_FALLBACK_HANDLER_ADDRESS,
|
|
227
226
|
ecdsaModuleAddress = BICONOMY_ADDRESSES.ECDSA_OWNERSHIP_REGISTRY_MODULE
|
|
228
|
-
}: SignerToBiconomySmartAccountParameters<TSource, TAddress>
|
|
229
|
-
): Promise<BiconomySmartAccount<TTransport, TChain>> {
|
|
227
|
+
}: SignerToBiconomySmartAccountParameters<entryPoint, TSource, TAddress>
|
|
228
|
+
): Promise<BiconomySmartAccount<entryPoint, TTransport, TChain>> {
|
|
229
|
+
const entryPointVersion = getEntryPointVersion(entryPointAddress)
|
|
230
|
+
|
|
231
|
+
if (entryPointVersion !== "v0.6") {
|
|
232
|
+
throw new Error("Only EntryPoint 0.6 is supported")
|
|
233
|
+
}
|
|
234
|
+
|
|
230
235
|
// Get the private key related account
|
|
231
236
|
const viemSigner: LocalAccount = {
|
|
232
237
|
...signer,
|
|
@@ -240,7 +245,6 @@ export async function signerToBiconomySmartAccount<
|
|
|
240
245
|
getAccountInitCode({
|
|
241
246
|
owner: viemSigner.address,
|
|
242
247
|
index,
|
|
243
|
-
factoryAddress,
|
|
244
248
|
ecdsaModuleAddress
|
|
245
249
|
})
|
|
246
250
|
|
|
@@ -294,14 +298,14 @@ export async function signerToBiconomySmartAccount<
|
|
|
294
298
|
...account,
|
|
295
299
|
client: client,
|
|
296
300
|
publicKey: accountAddress,
|
|
297
|
-
entryPoint:
|
|
301
|
+
entryPoint: entryPointAddress,
|
|
298
302
|
source: "biconomySmartAccount",
|
|
299
303
|
|
|
300
304
|
// Get the nonce of the smart account
|
|
301
305
|
async getNonce() {
|
|
302
306
|
return getAccountNonce(client, {
|
|
303
307
|
sender: accountAddress,
|
|
304
|
-
entryPoint:
|
|
308
|
+
entryPoint: entryPointAddress
|
|
305
309
|
})
|
|
306
310
|
},
|
|
307
311
|
|
|
@@ -312,7 +316,7 @@ export async function signerToBiconomySmartAccount<
|
|
|
312
316
|
...userOperation,
|
|
313
317
|
signature: "0x"
|
|
314
318
|
},
|
|
315
|
-
entryPoint:
|
|
319
|
+
entryPoint: entryPointAddress,
|
|
316
320
|
chainId: chainId
|
|
317
321
|
})
|
|
318
322
|
const signature = await signMessage(client, {
|
|
@@ -327,6 +331,31 @@ export async function signerToBiconomySmartAccount<
|
|
|
327
331
|
return signatureWithModuleAddress
|
|
328
332
|
},
|
|
329
333
|
|
|
334
|
+
async getFactory() {
|
|
335
|
+
if (smartAccountDeployed) return undefined
|
|
336
|
+
|
|
337
|
+
smartAccountDeployed = await isSmartAccountDeployed(
|
|
338
|
+
client,
|
|
339
|
+
accountAddress
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
if (smartAccountDeployed) return undefined
|
|
343
|
+
|
|
344
|
+
return factoryAddress
|
|
345
|
+
},
|
|
346
|
+
|
|
347
|
+
async getFactoryData() {
|
|
348
|
+
if (smartAccountDeployed) return undefined
|
|
349
|
+
|
|
350
|
+
smartAccountDeployed = await isSmartAccountDeployed(
|
|
351
|
+
client,
|
|
352
|
+
accountAddress
|
|
353
|
+
)
|
|
354
|
+
|
|
355
|
+
if (smartAccountDeployed) return undefined
|
|
356
|
+
return generateInitCode()
|
|
357
|
+
},
|
|
358
|
+
|
|
330
359
|
// Encode the init code
|
|
331
360
|
async getInitCode() {
|
|
332
361
|
if (smartAccountDeployed) return "0x"
|
|
@@ -338,7 +367,7 @@ export async function signerToBiconomySmartAccount<
|
|
|
338
367
|
|
|
339
368
|
if (smartAccountDeployed) return "0x"
|
|
340
369
|
|
|
341
|
-
return generateInitCode()
|
|
370
|
+
return concatHex([factoryAddress, await generateInitCode()])
|
|
342
371
|
},
|
|
343
372
|
|
|
344
373
|
// Encode the deploy call data
|
|
@@ -21,6 +21,8 @@ import {
|
|
|
21
21
|
import { getAccountNonce } from "../../actions/public/getAccountNonce"
|
|
22
22
|
import { getSenderAddress } from "../../actions/public/getSenderAddress"
|
|
23
23
|
import type { Prettify } from "../../types"
|
|
24
|
+
import type { ENTRYPOINT_ADDRESS_V06_TYPE } from "../../types/entrypoint"
|
|
25
|
+
import { getEntryPointVersion } from "../../utils"
|
|
24
26
|
import { getUserOperationHash } from "../../utils/getUserOperationHash"
|
|
25
27
|
import { isSmartAccountDeployed } from "../../utils/isSmartAccountDeployed"
|
|
26
28
|
import type { SmartAccount } from "../types"
|
|
@@ -31,9 +33,10 @@ import {
|
|
|
31
33
|
import { KernelExecuteAbi, KernelInitAbi } from "./abi/KernelAccountAbi"
|
|
32
34
|
|
|
33
35
|
export type KernelEcdsaSmartAccount<
|
|
36
|
+
entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE,
|
|
34
37
|
transport extends Transport = Transport,
|
|
35
38
|
chain extends Chain | undefined = Chain | undefined
|
|
36
|
-
> = SmartAccount<"kernelEcdsaSmartAccount", transport, chain>
|
|
39
|
+
> = SmartAccount<entryPoint, "kernelEcdsaSmartAccount", transport, chain>
|
|
37
40
|
|
|
38
41
|
/**
|
|
39
42
|
* The account creation ABI for a kernel smart account (from the KernelFactory)
|
|
@@ -94,13 +97,11 @@ const KERNEL_ADDRESSES: {
|
|
|
94
97
|
const getAccountInitCode = async ({
|
|
95
98
|
owner,
|
|
96
99
|
index,
|
|
97
|
-
factoryAddress,
|
|
98
100
|
accountLogicAddress,
|
|
99
101
|
ecdsaValidatorAddress
|
|
100
102
|
}: {
|
|
101
103
|
owner: Address
|
|
102
104
|
index: bigint
|
|
103
|
-
factoryAddress: Address
|
|
104
105
|
accountLogicAddress: Address
|
|
105
106
|
ecdsaValidatorAddress: Address
|
|
106
107
|
}): Promise<Hex> => {
|
|
@@ -114,14 +115,11 @@ const getAccountInitCode = async ({
|
|
|
114
115
|
})
|
|
115
116
|
|
|
116
117
|
// Build the account init code
|
|
117
|
-
return
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
args: [accountLogicAddress, initialisationData, index]
|
|
123
|
-
}) as Hex
|
|
124
|
-
])
|
|
118
|
+
return encodeFunctionData({
|
|
119
|
+
abi: createAccountAbi,
|
|
120
|
+
functionName: "createAccount",
|
|
121
|
+
args: [accountLogicAddress, initialisationData, index]
|
|
122
|
+
})
|
|
125
123
|
}
|
|
126
124
|
|
|
127
125
|
/**
|
|
@@ -134,20 +132,23 @@ const getAccountInitCode = async ({
|
|
|
134
132
|
* @param deployedAccountAddress
|
|
135
133
|
*/
|
|
136
134
|
const getAccountAddress = async <
|
|
135
|
+
entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE,
|
|
137
136
|
TTransport extends Transport = Transport,
|
|
138
137
|
TChain extends Chain | undefined = Chain | undefined
|
|
139
138
|
>({
|
|
140
139
|
client,
|
|
141
140
|
owner,
|
|
142
|
-
entryPoint,
|
|
141
|
+
entryPoint: entryPointAddress,
|
|
143
142
|
initCodeProvider,
|
|
144
143
|
ecdsaValidatorAddress,
|
|
145
|
-
deployedAccountAddress
|
|
144
|
+
deployedAccountAddress,
|
|
145
|
+
factoryAddress
|
|
146
146
|
}: {
|
|
147
147
|
client: Client<TTransport, TChain>
|
|
148
148
|
owner: Address
|
|
149
149
|
initCodeProvider: () => Promise<Hex>
|
|
150
|
-
|
|
150
|
+
factoryAddress: Address
|
|
151
|
+
entryPoint: entryPoint
|
|
151
152
|
ecdsaValidatorAddress: Address
|
|
152
153
|
deployedAccountAddress?: Address
|
|
153
154
|
}): Promise<Address> => {
|
|
@@ -191,21 +192,21 @@ const getAccountAddress = async <
|
|
|
191
192
|
}
|
|
192
193
|
|
|
193
194
|
// Find the init code for this account
|
|
194
|
-
const
|
|
195
|
+
const factoryData = await initCodeProvider()
|
|
195
196
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
entryPoint
|
|
197
|
+
return getSenderAddress<ENTRYPOINT_ADDRESS_V06_TYPE>(client, {
|
|
198
|
+
initCode: concatHex([factoryAddress, factoryData]),
|
|
199
|
+
entryPoint: entryPointAddress as ENTRYPOINT_ADDRESS_V06_TYPE
|
|
200
200
|
})
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
export type SignerToEcdsaKernelSmartAccountParameters<
|
|
204
|
+
entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE,
|
|
204
205
|
TSource extends string = "custom",
|
|
205
206
|
TAddress extends Address = Address
|
|
206
207
|
> = Prettify<{
|
|
207
208
|
signer: SmartAccountSigner<TSource, TAddress>
|
|
208
|
-
entryPoint:
|
|
209
|
+
entryPoint: entryPoint
|
|
209
210
|
address?: Address
|
|
210
211
|
index?: bigint
|
|
211
212
|
factoryAddress?: Address
|
|
@@ -225,6 +226,7 @@ export type SignerToEcdsaKernelSmartAccountParameters<
|
|
|
225
226
|
* @param deployedAccountAddress
|
|
226
227
|
*/
|
|
227
228
|
export async function signerToEcdsaKernelSmartAccount<
|
|
229
|
+
entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE,
|
|
228
230
|
TTransport extends Transport = Transport,
|
|
229
231
|
TChain extends Chain | undefined = Chain | undefined,
|
|
230
232
|
TSource extends string = "custom",
|
|
@@ -234,14 +236,20 @@ export async function signerToEcdsaKernelSmartAccount<
|
|
|
234
236
|
{
|
|
235
237
|
signer,
|
|
236
238
|
address,
|
|
237
|
-
entryPoint,
|
|
239
|
+
entryPoint: entryPointAddress,
|
|
238
240
|
index = 0n,
|
|
239
241
|
factoryAddress = KERNEL_ADDRESSES.FACTORY_ADDRESS,
|
|
240
242
|
accountLogicAddress = KERNEL_ADDRESSES.ACCOUNT_V2_2_LOGIC,
|
|
241
243
|
ecdsaValidatorAddress = KERNEL_ADDRESSES.ECDSA_VALIDATOR,
|
|
242
244
|
deployedAccountAddress
|
|
243
|
-
}: SignerToEcdsaKernelSmartAccountParameters<TSource, TAddress>
|
|
244
|
-
): Promise<KernelEcdsaSmartAccount<TTransport, TChain>> {
|
|
245
|
+
}: SignerToEcdsaKernelSmartAccountParameters<entryPoint, TSource, TAddress>
|
|
246
|
+
): Promise<KernelEcdsaSmartAccount<entryPoint, TTransport, TChain>> {
|
|
247
|
+
const entryPointVersion = getEntryPointVersion(entryPointAddress)
|
|
248
|
+
|
|
249
|
+
if (entryPointVersion !== "v0.6") {
|
|
250
|
+
throw new Error("Only EntryPoint 0.6 is supported")
|
|
251
|
+
}
|
|
252
|
+
|
|
245
253
|
// Get the private key related account
|
|
246
254
|
const viemSigner: LocalAccount = {
|
|
247
255
|
...signer,
|
|
@@ -255,7 +263,6 @@ export async function signerToEcdsaKernelSmartAccount<
|
|
|
255
263
|
getAccountInitCode({
|
|
256
264
|
owner: viemSigner.address,
|
|
257
265
|
index,
|
|
258
|
-
factoryAddress,
|
|
259
266
|
accountLogicAddress,
|
|
260
267
|
ecdsaValidatorAddress
|
|
261
268
|
})
|
|
@@ -263,13 +270,14 @@ export async function signerToEcdsaKernelSmartAccount<
|
|
|
263
270
|
// Fetch account address and chain id
|
|
264
271
|
const [accountAddress, chainId] = await Promise.all([
|
|
265
272
|
address ??
|
|
266
|
-
getAccountAddress<TTransport, TChain>({
|
|
273
|
+
getAccountAddress<entryPoint, TTransport, TChain>({
|
|
267
274
|
client,
|
|
268
|
-
entryPoint,
|
|
275
|
+
entryPoint: entryPointAddress,
|
|
269
276
|
owner: viemSigner.address,
|
|
270
277
|
ecdsaValidatorAddress,
|
|
271
278
|
initCodeProvider: generateInitCode,
|
|
272
|
-
deployedAccountAddress
|
|
279
|
+
deployedAccountAddress,
|
|
280
|
+
factoryAddress
|
|
273
281
|
}),
|
|
274
282
|
getChainId(client)
|
|
275
283
|
])
|
|
@@ -310,14 +318,14 @@ export async function signerToEcdsaKernelSmartAccount<
|
|
|
310
318
|
...account,
|
|
311
319
|
client: client,
|
|
312
320
|
publicKey: accountAddress,
|
|
313
|
-
entryPoint:
|
|
321
|
+
entryPoint: entryPointAddress,
|
|
314
322
|
source: "kernelEcdsaSmartAccount",
|
|
315
323
|
|
|
316
324
|
// Get the nonce of the smart account
|
|
317
325
|
async getNonce() {
|
|
318
326
|
return getAccountNonce(client, {
|
|
319
327
|
sender: accountAddress,
|
|
320
|
-
entryPoint:
|
|
328
|
+
entryPoint: entryPointAddress
|
|
321
329
|
})
|
|
322
330
|
},
|
|
323
331
|
|
|
@@ -328,7 +336,7 @@ export async function signerToEcdsaKernelSmartAccount<
|
|
|
328
336
|
...userOperation,
|
|
329
337
|
signature: "0x"
|
|
330
338
|
},
|
|
331
|
-
entryPoint:
|
|
339
|
+
entryPoint: entryPointAddress,
|
|
332
340
|
chainId: chainId
|
|
333
341
|
})
|
|
334
342
|
const signature = await signMessage(client, {
|
|
@@ -350,6 +358,32 @@ export async function signerToEcdsaKernelSmartAccount<
|
|
|
350
358
|
|
|
351
359
|
if (smartAccountDeployed) return "0x"
|
|
352
360
|
|
|
361
|
+
return concatHex([factoryAddress, await generateInitCode()])
|
|
362
|
+
},
|
|
363
|
+
|
|
364
|
+
async getFactory() {
|
|
365
|
+
if (smartAccountDeployed) return undefined
|
|
366
|
+
|
|
367
|
+
smartAccountDeployed = await isSmartAccountDeployed(
|
|
368
|
+
client,
|
|
369
|
+
accountAddress
|
|
370
|
+
)
|
|
371
|
+
|
|
372
|
+
if (smartAccountDeployed) return undefined
|
|
373
|
+
|
|
374
|
+
return factoryAddress
|
|
375
|
+
},
|
|
376
|
+
|
|
377
|
+
async getFactoryData() {
|
|
378
|
+
if (smartAccountDeployed) return undefined
|
|
379
|
+
|
|
380
|
+
smartAccountDeployed = await isSmartAccountDeployed(
|
|
381
|
+
client,
|
|
382
|
+
accountAddress
|
|
383
|
+
)
|
|
384
|
+
|
|
385
|
+
if (smartAccountDeployed) return undefined
|
|
386
|
+
|
|
353
387
|
return generateInitCode()
|
|
354
388
|
},
|
|
355
389
|
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { type Chain, type Client, type Hex, type Transport } from "viem"
|
|
2
2
|
import { privateKeyToAccount } from "viem/accounts"
|
|
3
|
-
import type { Prettify } from "../../types"
|
|
3
|
+
import type { ENTRYPOINT_ADDRESS_V06_TYPE, Prettify } from "../../types"
|
|
4
4
|
import {
|
|
5
5
|
type SafeSmartAccount,
|
|
6
6
|
type SignerToSafeSmartAccountParameters,
|
|
7
7
|
signerToSafeSmartAccount
|
|
8
8
|
} from "./signerToSafeSmartAccount"
|
|
9
9
|
|
|
10
|
-
export type PrivateKeyToSafeSmartAccountParameters
|
|
10
|
+
export type PrivateKeyToSafeSmartAccountParameters<
|
|
11
|
+
entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE
|
|
12
|
+
> = Prettify<
|
|
11
13
|
{
|
|
12
14
|
privateKey: Hex
|
|
13
|
-
} & Omit<SignerToSafeSmartAccountParameters
|
|
15
|
+
} & Omit<SignerToSafeSmartAccountParameters<entryPoint>, "signer">
|
|
14
16
|
>
|
|
15
17
|
|
|
16
18
|
/**
|
|
@@ -19,12 +21,13 @@ export type PrivateKeyToSafeSmartAccountParameters = Prettify<
|
|
|
19
21
|
* @returns A Private Key Simple Account.
|
|
20
22
|
*/
|
|
21
23
|
export async function privateKeyToSafeSmartAccount<
|
|
24
|
+
entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE,
|
|
22
25
|
TTransport extends Transport = Transport,
|
|
23
26
|
TChain extends Chain | undefined = Chain | undefined
|
|
24
27
|
>(
|
|
25
28
|
client: Client<TTransport, TChain, undefined>,
|
|
26
|
-
{ privateKey, ...rest }: PrivateKeyToSafeSmartAccountParameters
|
|
27
|
-
): Promise<SafeSmartAccount<TTransport, TChain>> {
|
|
29
|
+
{ privateKey, ...rest }: PrivateKeyToSafeSmartAccountParameters<entryPoint>
|
|
30
|
+
): Promise<SafeSmartAccount<entryPoint, TTransport, TChain>> {
|
|
28
31
|
const privateKeyAccount = privateKeyToAccount(privateKey)
|
|
29
32
|
|
|
30
33
|
return signerToSafeSmartAccount(client, {
|
|
@@ -28,7 +28,9 @@ import {
|
|
|
28
28
|
signTypedData
|
|
29
29
|
} from "viem/actions"
|
|
30
30
|
import { getAccountNonce } from "../../actions/public/getAccountNonce"
|
|
31
|
-
import type { Prettify } from "../../types"
|
|
31
|
+
import type { ENTRYPOINT_ADDRESS_V06_TYPE, Prettify } from "../../types"
|
|
32
|
+
import type { EntryPoint } from "../../types/entrypoint"
|
|
33
|
+
import { getEntryPointVersion } from "../../utils"
|
|
32
34
|
import { isSmartAccountDeployed } from "../../utils/isSmartAccountDeployed"
|
|
33
35
|
import {
|
|
34
36
|
SignTransactionNotSupportedBySmartAccount,
|
|
@@ -172,9 +174,11 @@ const encodeMultiSend = (
|
|
|
172
174
|
}
|
|
173
175
|
|
|
174
176
|
export type SafeSmartAccount<
|
|
177
|
+
entryPoint extends
|
|
178
|
+
ENTRYPOINT_ADDRESS_V06_TYPE = ENTRYPOINT_ADDRESS_V06_TYPE,
|
|
175
179
|
transport extends Transport = Transport,
|
|
176
180
|
chain extends Chain | undefined = Chain | undefined
|
|
177
|
-
> = SmartAccount<"SafeSmartAccount", transport, chain>
|
|
181
|
+
> = SmartAccount<entryPoint, "SafeSmartAccount", transport, chain>
|
|
178
182
|
|
|
179
183
|
const getInitializerCode = async ({
|
|
180
184
|
owner,
|
|
@@ -292,7 +296,6 @@ const getAccountInitCode = async ({
|
|
|
292
296
|
owner,
|
|
293
297
|
addModuleLibAddress,
|
|
294
298
|
safe4337ModuleAddress,
|
|
295
|
-
safeProxyFactoryAddress,
|
|
296
299
|
safeSingletonAddress,
|
|
297
300
|
multiSendAddress,
|
|
298
301
|
saltNonce = 0n,
|
|
@@ -302,7 +305,6 @@ const getAccountInitCode = async ({
|
|
|
302
305
|
owner: Address
|
|
303
306
|
addModuleLibAddress: Address
|
|
304
307
|
safe4337ModuleAddress: Address
|
|
305
|
-
safeProxyFactoryAddress: Address
|
|
306
308
|
safeSingletonAddress: Address
|
|
307
309
|
multiSendAddress: Address
|
|
308
310
|
saltNonce?: bigint
|
|
@@ -359,7 +361,7 @@ const getAccountInitCode = async ({
|
|
|
359
361
|
args: [safeSingletonAddress, initializer, saltNonce]
|
|
360
362
|
})
|
|
361
363
|
|
|
362
|
-
return
|
|
364
|
+
return initCodeCallData
|
|
363
365
|
}
|
|
364
366
|
|
|
365
367
|
const getAccountAddress = async <
|
|
@@ -490,12 +492,13 @@ const getDefaultAddresses = (
|
|
|
490
492
|
}
|
|
491
493
|
|
|
492
494
|
export type SignerToSafeSmartAccountParameters<
|
|
495
|
+
entryPoint extends EntryPoint,
|
|
493
496
|
TSource extends string = "custom",
|
|
494
497
|
TAddress extends Address = Address
|
|
495
498
|
> = Prettify<{
|
|
496
499
|
signer: SmartAccountSigner<TSource, TAddress>
|
|
497
500
|
safeVersion: SafeVersion
|
|
498
|
-
entryPoint:
|
|
501
|
+
entryPoint: entryPoint
|
|
499
502
|
address?: Address
|
|
500
503
|
addModuleLibAddress?: Address
|
|
501
504
|
safe4337ModuleAddress?: Address
|
|
@@ -520,6 +523,7 @@ export type SignerToSafeSmartAccountParameters<
|
|
|
520
523
|
* @returns A Private Key Simple Account.
|
|
521
524
|
*/
|
|
522
525
|
export async function signerToSafeSmartAccount<
|
|
526
|
+
entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE,
|
|
523
527
|
TTransport extends Transport = Transport,
|
|
524
528
|
TChain extends Chain | undefined = Chain | undefined,
|
|
525
529
|
TSource extends string = "custom",
|
|
@@ -530,7 +534,7 @@ export async function signerToSafeSmartAccount<
|
|
|
530
534
|
signer,
|
|
531
535
|
address,
|
|
532
536
|
safeVersion,
|
|
533
|
-
entryPoint,
|
|
537
|
+
entryPoint: entryPointAddress,
|
|
534
538
|
addModuleLibAddress: _addModuleLibAddress,
|
|
535
539
|
safe4337ModuleAddress: _safe4337ModuleAddress,
|
|
536
540
|
safeProxyFactoryAddress: _safeProxyFactoryAddress,
|
|
@@ -542,8 +546,14 @@ export async function signerToSafeSmartAccount<
|
|
|
542
546
|
validAfter = 0,
|
|
543
547
|
safeModules = [],
|
|
544
548
|
setupTransactions = []
|
|
545
|
-
}: SignerToSafeSmartAccountParameters<TSource, TAddress>
|
|
546
|
-
): Promise<SafeSmartAccount<TTransport, TChain>> {
|
|
549
|
+
}: SignerToSafeSmartAccountParameters<entryPoint, TSource, TAddress>
|
|
550
|
+
): Promise<SafeSmartAccount<entryPoint, TTransport, TChain>> {
|
|
551
|
+
const entryPointVersion = getEntryPointVersion(entryPointAddress)
|
|
552
|
+
|
|
553
|
+
if (entryPointVersion !== "v0.6") {
|
|
554
|
+
throw new Error("Only EntryPoint 0.6 is supported")
|
|
555
|
+
}
|
|
556
|
+
|
|
547
557
|
const chainId = await getChainId(client)
|
|
548
558
|
|
|
549
559
|
const viemSigner: LocalAccount = {
|
|
@@ -647,16 +657,16 @@ export async function signerToSafeSmartAccount<
|
|
|
647
657
|
}
|
|
648
658
|
})
|
|
649
659
|
|
|
650
|
-
|
|
660
|
+
const safeSmartAccount: SafeSmartAccount<entryPoint, TTransport, TChain> = {
|
|
651
661
|
...account,
|
|
652
662
|
client: client,
|
|
653
663
|
publicKey: accountAddress,
|
|
654
|
-
entryPoint:
|
|
664
|
+
entryPoint: entryPointAddress,
|
|
655
665
|
source: "SafeSmartAccount",
|
|
656
666
|
async getNonce() {
|
|
657
667
|
return getAccountNonce(client, {
|
|
658
668
|
sender: accountAddress,
|
|
659
|
-
entryPoint:
|
|
669
|
+
entryPoint: entryPointAddress
|
|
660
670
|
})
|
|
661
671
|
},
|
|
662
672
|
async signUserOperation(userOperation) {
|
|
@@ -674,7 +684,7 @@ export async function signerToSafeSmartAccount<
|
|
|
674
684
|
message: {
|
|
675
685
|
safe: accountAddress,
|
|
676
686
|
callData: userOperation.callData,
|
|
677
|
-
entryPoint:
|
|
687
|
+
entryPoint: entryPointAddress,
|
|
678
688
|
nonce: userOperation.nonce,
|
|
679
689
|
initCode: userOperation.initCode,
|
|
680
690
|
maxFeePerGas: userOperation.maxFeePerGas,
|
|
@@ -713,11 +723,39 @@ export async function signerToSafeSmartAccount<
|
|
|
713
723
|
|
|
714
724
|
if (safeDeployed) return "0x"
|
|
715
725
|
|
|
716
|
-
|
|
726
|
+
const initCodeCallData = await getAccountInitCode({
|
|
727
|
+
owner: viemSigner.address,
|
|
728
|
+
addModuleLibAddress,
|
|
729
|
+
safe4337ModuleAddress,
|
|
730
|
+
safeSingletonAddress,
|
|
731
|
+
multiSendAddress,
|
|
732
|
+
saltNonce,
|
|
733
|
+
setupTransactions,
|
|
734
|
+
safeModules
|
|
735
|
+
})
|
|
736
|
+
|
|
737
|
+
return concatHex([safeProxyFactoryAddress, initCodeCallData])
|
|
738
|
+
},
|
|
739
|
+
async getFactory() {
|
|
740
|
+
if (safeDeployed) return undefined
|
|
741
|
+
|
|
742
|
+
safeDeployed = await isSmartAccountDeployed(client, accountAddress)
|
|
743
|
+
|
|
744
|
+
if (safeDeployed) return undefined
|
|
745
|
+
|
|
746
|
+
return safeProxyFactoryAddress
|
|
747
|
+
},
|
|
748
|
+
async getFactoryData() {
|
|
749
|
+
if (safeDeployed) return undefined
|
|
750
|
+
|
|
751
|
+
safeDeployed = await isSmartAccountDeployed(client, accountAddress)
|
|
752
|
+
|
|
753
|
+
if (safeDeployed) return undefined
|
|
754
|
+
|
|
755
|
+
return await getAccountInitCode({
|
|
717
756
|
owner: viemSigner.address,
|
|
718
757
|
addModuleLibAddress,
|
|
719
758
|
safe4337ModuleAddress,
|
|
720
|
-
safeProxyFactoryAddress,
|
|
721
759
|
safeSingletonAddress,
|
|
722
760
|
multiSendAddress,
|
|
723
761
|
saltNonce,
|
|
@@ -784,13 +822,13 @@ export async function signerToSafeSmartAccount<
|
|
|
784
822
|
type: "uint8"
|
|
785
823
|
}
|
|
786
824
|
],
|
|
787
|
-
name: "
|
|
825
|
+
name: "executeUserOpWithErrorString",
|
|
788
826
|
outputs: [],
|
|
789
827
|
stateMutability: "nonpayable",
|
|
790
828
|
type: "function"
|
|
791
829
|
}
|
|
792
830
|
],
|
|
793
|
-
functionName: "
|
|
831
|
+
functionName: "executeUserOpWithErrorString",
|
|
794
832
|
args: [to, value, data, operationType]
|
|
795
833
|
})
|
|
796
834
|
},
|
|
@@ -798,4 +836,6 @@ export async function signerToSafeSmartAccount<
|
|
|
798
836
|
return "0x000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
|
|
799
837
|
}
|
|
800
838
|
}
|
|
839
|
+
|
|
840
|
+
return safeSmartAccount
|
|
801
841
|
}
|
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type Address,
|
|
3
|
+
type Chain,
|
|
4
|
+
type Client,
|
|
5
|
+
type Hex,
|
|
6
|
+
type Transport
|
|
7
|
+
} from "viem"
|
|
2
8
|
import { privateKeyToAccount } from "viem/accounts"
|
|
3
|
-
import type { Prettify } from "../../types"
|
|
9
|
+
import type { EntryPoint, Prettify } from "../../types"
|
|
4
10
|
import {
|
|
5
11
|
type SignerToSimpleSmartAccountParameters,
|
|
6
12
|
type SimpleSmartAccount,
|
|
7
13
|
signerToSimpleSmartAccount
|
|
8
14
|
} from "./signerToSimpleSmartAccount"
|
|
9
15
|
|
|
10
|
-
export type PrivateKeyToSimpleSmartAccountParameters
|
|
16
|
+
export type PrivateKeyToSimpleSmartAccountParameters<
|
|
17
|
+
entryPoint extends EntryPoint
|
|
18
|
+
> = Prettify<
|
|
11
19
|
{
|
|
12
20
|
privateKey: Hex
|
|
13
|
-
} & Omit<SignerToSimpleSmartAccountParameters
|
|
21
|
+
} & Omit<SignerToSimpleSmartAccountParameters<entryPoint>, "signer">
|
|
14
22
|
>
|
|
15
23
|
|
|
16
24
|
/**
|
|
@@ -19,15 +27,25 @@ export type PrivateKeyToSimpleSmartAccountParameters = Prettify<
|
|
|
19
27
|
* @returns A Private Key Simple Account.
|
|
20
28
|
*/
|
|
21
29
|
export async function privateKeyToSimpleSmartAccount<
|
|
30
|
+
entryPoint extends EntryPoint,
|
|
22
31
|
TTransport extends Transport = Transport,
|
|
23
32
|
TChain extends Chain | undefined = Chain | undefined
|
|
24
33
|
>(
|
|
25
34
|
client: Client<TTransport, TChain, undefined>,
|
|
26
|
-
{
|
|
27
|
-
|
|
35
|
+
{
|
|
36
|
+
privateKey,
|
|
37
|
+
...rest
|
|
38
|
+
}: PrivateKeyToSimpleSmartAccountParameters<entryPoint>
|
|
39
|
+
): Promise<SimpleSmartAccount<entryPoint, TTransport, TChain>> {
|
|
28
40
|
const privateKeyAccount = privateKeyToAccount(privateKey)
|
|
29
41
|
|
|
30
|
-
return signerToSimpleSmartAccount
|
|
42
|
+
return signerToSimpleSmartAccount<
|
|
43
|
+
entryPoint,
|
|
44
|
+
TTransport,
|
|
45
|
+
TChain,
|
|
46
|
+
"privateKey",
|
|
47
|
+
Address
|
|
48
|
+
>(client, {
|
|
31
49
|
signer: privateKeyAccount,
|
|
32
50
|
...rest
|
|
33
51
|
})
|