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
|
@@ -1,11 +1,86 @@
|
|
|
1
1
|
import type { Address, Hash, Hex } from "viem"
|
|
2
|
-
import { encodeAbiParameters, keccak256 } from "viem"
|
|
2
|
+
import { concat, encodeAbiParameters, keccak256, pad, toHex } from "viem"
|
|
3
|
+
import type { EntryPoint, GetEntryPointVersion } from "../types"
|
|
3
4
|
import type { UserOperation } from "../types/userOperation"
|
|
5
|
+
import { getEntryPointVersion } from "./getEntryPointVersion"
|
|
4
6
|
|
|
5
|
-
function packUserOp
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
function packUserOp<entryPoint extends EntryPoint>({
|
|
8
|
+
userOperation,
|
|
9
|
+
entryPoint: entryPointAddress
|
|
10
|
+
}: {
|
|
11
|
+
userOperation: UserOperation<GetEntryPointVersion<entryPoint>>
|
|
12
|
+
entryPoint: entryPoint
|
|
13
|
+
}): Hex {
|
|
14
|
+
const entryPointVersion = getEntryPointVersion(entryPointAddress)
|
|
15
|
+
|
|
16
|
+
if (entryPointVersion === "v0.6") {
|
|
17
|
+
const userOperationVersion0_6 = userOperation as UserOperation<"v0.6">
|
|
18
|
+
const hashedInitCode = keccak256(userOperationVersion0_6.initCode)
|
|
19
|
+
const hashedCallData = keccak256(userOperationVersion0_6.callData)
|
|
20
|
+
const hashedPaymasterAndData = keccak256(
|
|
21
|
+
userOperationVersion0_6.paymasterAndData
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
return encodeAbiParameters(
|
|
25
|
+
[
|
|
26
|
+
{ type: "address" },
|
|
27
|
+
{ type: "uint256" },
|
|
28
|
+
{ type: "bytes32" },
|
|
29
|
+
{ type: "bytes32" },
|
|
30
|
+
{ type: "uint256" },
|
|
31
|
+
{ type: "uint256" },
|
|
32
|
+
{ type: "uint256" },
|
|
33
|
+
{ type: "uint256" },
|
|
34
|
+
{ type: "uint256" },
|
|
35
|
+
{ type: "bytes32" }
|
|
36
|
+
],
|
|
37
|
+
[
|
|
38
|
+
userOperationVersion0_6.sender as Address,
|
|
39
|
+
userOperationVersion0_6.nonce,
|
|
40
|
+
hashedInitCode,
|
|
41
|
+
hashedCallData,
|
|
42
|
+
userOperationVersion0_6.callGasLimit,
|
|
43
|
+
userOperationVersion0_6.verificationGasLimit,
|
|
44
|
+
userOperationVersion0_6.preVerificationGas,
|
|
45
|
+
userOperationVersion0_6.maxFeePerGas,
|
|
46
|
+
userOperationVersion0_6.maxPriorityFeePerGas,
|
|
47
|
+
hashedPaymasterAndData
|
|
48
|
+
]
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const userOperationVersion0_7 = userOperation as UserOperation<"v0.7">
|
|
53
|
+
const hashedInitCode = keccak256(
|
|
54
|
+
userOperationVersion0_7.factory && userOperationVersion0_7.factoryData
|
|
55
|
+
? concat([
|
|
56
|
+
userOperationVersion0_7.factory,
|
|
57
|
+
userOperationVersion0_7.factoryData
|
|
58
|
+
])
|
|
59
|
+
: "0x"
|
|
60
|
+
)
|
|
61
|
+
const hashedCallData = keccak256(userOperationVersion0_7.callData)
|
|
62
|
+
const hashedPaymasterAndData = keccak256(
|
|
63
|
+
userOperationVersion0_7.paymaster &&
|
|
64
|
+
userOperationVersion0_7.paymasterVerificationGasLimit &&
|
|
65
|
+
userOperationVersion0_7.paymasterPostOpGasLimit &&
|
|
66
|
+
userOperationVersion0_7.paymasterData
|
|
67
|
+
? concat([
|
|
68
|
+
userOperationVersion0_7.paymaster,
|
|
69
|
+
pad(
|
|
70
|
+
toHex(
|
|
71
|
+
userOperationVersion0_7.paymasterVerificationGasLimit
|
|
72
|
+
),
|
|
73
|
+
{
|
|
74
|
+
size: 16
|
|
75
|
+
}
|
|
76
|
+
),
|
|
77
|
+
pad(toHex(userOperationVersion0_7.paymasterPostOpGasLimit), {
|
|
78
|
+
size: 16
|
|
79
|
+
}),
|
|
80
|
+
userOperationVersion0_7.paymasterData
|
|
81
|
+
])
|
|
82
|
+
: "0x"
|
|
83
|
+
)
|
|
9
84
|
|
|
10
85
|
return encodeAbiParameters(
|
|
11
86
|
[
|
|
@@ -13,31 +88,37 @@ function packUserOp({ userOperation }: { userOperation: UserOperation }): Hex {
|
|
|
13
88
|
{ type: "uint256" },
|
|
14
89
|
{ type: "bytes32" },
|
|
15
90
|
{ type: "bytes32" },
|
|
91
|
+
{ type: "bytes32" },
|
|
16
92
|
{ type: "uint256" },
|
|
17
|
-
{ type: "
|
|
18
|
-
{ type: "uint256" },
|
|
19
|
-
{ type: "uint256" },
|
|
20
|
-
{ type: "uint256" },
|
|
93
|
+
{ type: "bytes32" },
|
|
21
94
|
{ type: "bytes32" }
|
|
22
95
|
],
|
|
23
96
|
[
|
|
24
|
-
|
|
25
|
-
|
|
97
|
+
userOperationVersion0_7.sender as Address,
|
|
98
|
+
userOperationVersion0_7.nonce,
|
|
26
99
|
hashedInitCode,
|
|
27
100
|
hashedCallData,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
101
|
+
concat([
|
|
102
|
+
pad(toHex(userOperationVersion0_7.verificationGasLimit), {
|
|
103
|
+
size: 16
|
|
104
|
+
}),
|
|
105
|
+
pad(toHex(userOperationVersion0_7.callGasLimit), { size: 16 })
|
|
106
|
+
]),
|
|
107
|
+
userOperationVersion0_7.preVerificationGas,
|
|
108
|
+
concat([
|
|
109
|
+
pad(toHex(userOperationVersion0_7.maxPriorityFeePerGas), {
|
|
110
|
+
size: 16
|
|
111
|
+
}),
|
|
112
|
+
pad(toHex(userOperationVersion0_7.maxFeePerGas), { size: 16 })
|
|
113
|
+
]),
|
|
33
114
|
hashedPaymasterAndData
|
|
34
115
|
]
|
|
35
116
|
)
|
|
36
117
|
}
|
|
37
118
|
|
|
38
|
-
export type GetUserOperationHashParams = {
|
|
39
|
-
userOperation: UserOperation
|
|
40
|
-
entryPoint:
|
|
119
|
+
export type GetUserOperationHashParams<entryPoint extends EntryPoint> = {
|
|
120
|
+
userOperation: UserOperation<GetEntryPointVersion<entryPoint>>
|
|
121
|
+
entryPoint: entryPoint
|
|
41
122
|
chainId: number
|
|
42
123
|
}
|
|
43
124
|
|
|
@@ -62,14 +143,23 @@ export type GetUserOperationHashParams = {
|
|
|
62
143
|
* // Returns "0xe9fad2cd67f9ca1d0b7a6513b2a42066784c8df938518da2b51bb8cc9a89ea34"
|
|
63
144
|
*
|
|
64
145
|
*/
|
|
65
|
-
export const getUserOperationHash = ({
|
|
146
|
+
export const getUserOperationHash = <entryPoint extends EntryPoint>({
|
|
66
147
|
userOperation,
|
|
67
|
-
entryPoint,
|
|
148
|
+
entryPoint: entryPointAddress,
|
|
68
149
|
chainId
|
|
69
|
-
}: GetUserOperationHashParams): Hash => {
|
|
150
|
+
}: GetUserOperationHashParams<entryPoint>): Hash => {
|
|
70
151
|
const encoded = encodeAbiParameters(
|
|
71
152
|
[{ type: "bytes32" }, { type: "address" }, { type: "uint256" }],
|
|
72
|
-
[
|
|
153
|
+
[
|
|
154
|
+
keccak256(
|
|
155
|
+
packUserOp<entryPoint>({
|
|
156
|
+
userOperation,
|
|
157
|
+
entryPoint: entryPointAddress
|
|
158
|
+
})
|
|
159
|
+
),
|
|
160
|
+
entryPointAddress,
|
|
161
|
+
BigInt(chainId)
|
|
162
|
+
]
|
|
73
163
|
) as `0x${string}`
|
|
74
164
|
|
|
75
165
|
return keccak256(encoded)
|
package/utils/index.ts
CHANGED
|
@@ -24,6 +24,11 @@ export function parseAccount(account: Address | Account): Account {
|
|
|
24
24
|
return { address: account, type: "json-rpc" }
|
|
25
25
|
return account
|
|
26
26
|
}
|
|
27
|
+
import {
|
|
28
|
+
ENTRYPOINT_ADDRESS_V06,
|
|
29
|
+
ENTRYPOINT_ADDRESS_V07,
|
|
30
|
+
getEntryPointVersion
|
|
31
|
+
} from "./getEntryPointVersion"
|
|
27
32
|
|
|
28
33
|
export {
|
|
29
34
|
transactionReceiptStatus,
|
|
@@ -39,5 +44,8 @@ export {
|
|
|
39
44
|
AccountOrClientNotFoundError,
|
|
40
45
|
isSmartAccountDeployed,
|
|
41
46
|
providerToSmartAccountSigner,
|
|
42
|
-
getAddressFromInitCodeOrPaymasterAndData
|
|
47
|
+
getAddressFromInitCodeOrPaymasterAndData,
|
|
48
|
+
getEntryPointVersion,
|
|
49
|
+
ENTRYPOINT_ADDRESS_V06,
|
|
50
|
+
ENTRYPOINT_ADDRESS_V07
|
|
43
51
|
}
|
|
@@ -6,10 +6,13 @@ import {
|
|
|
6
6
|
} from "viem"
|
|
7
7
|
import { walletClientToSmartAccountSigner } from "./walletClientToSmartAccountSigner"
|
|
8
8
|
|
|
9
|
-
export const providerToSmartAccountSigner = async (
|
|
10
|
-
provider
|
|
9
|
+
export const providerToSmartAccountSigner = async ({
|
|
10
|
+
provider,
|
|
11
|
+
signerAddress
|
|
12
|
+
}: {
|
|
13
|
+
provider: EIP1193Provider
|
|
11
14
|
signerAddress?: Hex
|
|
12
|
-
) => {
|
|
15
|
+
}) => {
|
|
13
16
|
let account: Hex
|
|
14
17
|
if (!signerAddress) {
|
|
15
18
|
;[account] = await provider.request({ method: "eth_requestAccounts" })
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type Account,
|
|
3
|
-
type Address,
|
|
4
3
|
BaseError,
|
|
5
4
|
type Chain,
|
|
6
5
|
type Client,
|
|
@@ -8,12 +7,17 @@ import {
|
|
|
8
7
|
type Hex,
|
|
9
8
|
type Transport
|
|
10
9
|
} from "viem"
|
|
11
|
-
import
|
|
10
|
+
import type {
|
|
11
|
+
EntryPoint,
|
|
12
|
+
GetAccountParameterWithClient,
|
|
13
|
+
GetEntryPointVersion
|
|
14
|
+
} from "../types/"
|
|
12
15
|
import type { UserOperation } from "../types/userOperation"
|
|
13
16
|
import { parseAccount } from "./"
|
|
14
17
|
import { getUserOperationHash } from "./getUserOperationHash"
|
|
15
18
|
|
|
16
19
|
export type SignUserOperationHashWithECDSAParams<
|
|
20
|
+
entryPoint extends EntryPoint,
|
|
17
21
|
TTransport extends Transport = Transport,
|
|
18
22
|
TChain extends Chain | undefined = Chain | undefined,
|
|
19
23
|
TAccount extends Account | undefined = Account | undefined
|
|
@@ -27,8 +31,8 @@ export type SignUserOperationHashWithECDSAParams<
|
|
|
27
31
|
}
|
|
28
32
|
| {
|
|
29
33
|
hash?: undefined
|
|
30
|
-
userOperation: UserOperation
|
|
31
|
-
entryPoint:
|
|
34
|
+
userOperation: UserOperation<GetEntryPointVersion<entryPoint>>
|
|
35
|
+
entryPoint: entryPoint
|
|
32
36
|
chainId: number
|
|
33
37
|
}
|
|
34
38
|
)
|
|
@@ -73,6 +77,7 @@ export class AccountOrClientNotFoundError extends BaseError {
|
|
|
73
77
|
*
|
|
74
78
|
*/
|
|
75
79
|
export const signUserOperationHashWithECDSA = async <
|
|
80
|
+
entryPoint extends EntryPoint,
|
|
76
81
|
TTransport extends Transport = Transport,
|
|
77
82
|
TChain extends Chain | undefined = Chain | undefined,
|
|
78
83
|
TAccount extends Account | undefined = Account | undefined
|
|
@@ -82,8 +87,9 @@ export const signUserOperationHashWithECDSA = async <
|
|
|
82
87
|
hash,
|
|
83
88
|
userOperation,
|
|
84
89
|
chainId,
|
|
85
|
-
entryPoint
|
|
90
|
+
entryPoint: entryPointAddress
|
|
86
91
|
}: SignUserOperationHashWithECDSAParams<
|
|
92
|
+
entryPoint,
|
|
87
93
|
TTransport,
|
|
88
94
|
TChain,
|
|
89
95
|
TAccount
|
|
@@ -99,10 +105,10 @@ export const signUserOperationHashWithECDSA = async <
|
|
|
99
105
|
if (hash) {
|
|
100
106
|
userOperationHash = hash
|
|
101
107
|
} else {
|
|
102
|
-
userOperationHash = getUserOperationHash({
|
|
108
|
+
userOperationHash = getUserOperationHash<entryPoint>({
|
|
103
109
|
userOperation,
|
|
104
110
|
chainId,
|
|
105
|
-
entryPoint
|
|
111
|
+
entryPoint: entryPointAddress
|
|
106
112
|
})
|
|
107
113
|
}
|
|
108
114
|
|