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
|
@@ -14,7 +14,13 @@ import { toAccount } from "viem/accounts"
|
|
|
14
14
|
import { getChainId, signMessage, signTypedData } from "viem/actions"
|
|
15
15
|
import { getAccountNonce } from "../../actions/public/getAccountNonce"
|
|
16
16
|
import { getSenderAddress } from "../../actions/public/getSenderAddress"
|
|
17
|
-
import type {
|
|
17
|
+
import type {
|
|
18
|
+
ENTRYPOINT_ADDRESS_V06_TYPE,
|
|
19
|
+
ENTRYPOINT_ADDRESS_V07_TYPE,
|
|
20
|
+
Prettify
|
|
21
|
+
} from "../../types"
|
|
22
|
+
import type { EntryPoint } from "../../types/entrypoint"
|
|
23
|
+
import { getEntryPointVersion } from "../../utils"
|
|
18
24
|
import { getUserOperationHash } from "../../utils/getUserOperationHash"
|
|
19
25
|
import { isSmartAccountDeployed } from "../../utils/isSmartAccountDeployed"
|
|
20
26
|
import {
|
|
@@ -24,83 +30,90 @@ import {
|
|
|
24
30
|
} from "../types"
|
|
25
31
|
|
|
26
32
|
export type SimpleSmartAccount<
|
|
33
|
+
entryPoint extends EntryPoint,
|
|
27
34
|
transport extends Transport = Transport,
|
|
28
35
|
chain extends Chain | undefined = Chain | undefined
|
|
29
|
-
> = SmartAccount<"SimpleSmartAccount", transport, chain>
|
|
36
|
+
> = SmartAccount<entryPoint, "SimpleSmartAccount", transport, chain>
|
|
30
37
|
|
|
31
|
-
const getAccountInitCode = async (
|
|
32
|
-
factoryAddress: Address,
|
|
33
|
-
owner: Address,
|
|
34
|
-
index = 0n
|
|
35
|
-
): Promise<Hex> => {
|
|
38
|
+
const getAccountInitCode = async (owner: Address, index = 0n): Promise<Hex> => {
|
|
36
39
|
if (!owner) throw new Error("Owner account not found")
|
|
37
40
|
|
|
38
|
-
return
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
args: [owner, index]
|
|
69
|
-
}) as Hex
|
|
70
|
-
])
|
|
41
|
+
return encodeFunctionData({
|
|
42
|
+
abi: [
|
|
43
|
+
{
|
|
44
|
+
inputs: [
|
|
45
|
+
{
|
|
46
|
+
internalType: "address",
|
|
47
|
+
name: "owner",
|
|
48
|
+
type: "address"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
internalType: "uint256",
|
|
52
|
+
name: "salt",
|
|
53
|
+
type: "uint256"
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
name: "createAccount",
|
|
57
|
+
outputs: [
|
|
58
|
+
{
|
|
59
|
+
internalType: "contract SimpleAccount",
|
|
60
|
+
name: "ret",
|
|
61
|
+
type: "address"
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
stateMutability: "nonpayable",
|
|
65
|
+
type: "function"
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
functionName: "createAccount",
|
|
69
|
+
args: [owner, index]
|
|
70
|
+
})
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
const getAccountAddress = async <
|
|
74
|
+
entryPoint extends EntryPoint,
|
|
74
75
|
TTransport extends Transport = Transport,
|
|
75
76
|
TChain extends Chain | undefined = Chain | undefined
|
|
76
77
|
>({
|
|
77
78
|
client,
|
|
78
79
|
factoryAddress,
|
|
79
|
-
entryPoint,
|
|
80
|
+
entryPoint: entryPointAddress,
|
|
80
81
|
owner,
|
|
81
82
|
index = 0n
|
|
82
83
|
}: {
|
|
83
84
|
client: Client<TTransport, TChain>
|
|
84
85
|
factoryAddress: Address
|
|
85
86
|
owner: Address
|
|
86
|
-
entryPoint:
|
|
87
|
+
entryPoint: entryPoint
|
|
87
88
|
index?: bigint
|
|
88
89
|
}): Promise<Address> => {
|
|
89
|
-
const
|
|
90
|
+
const entryPointVersion = getEntryPointVersion(entryPointAddress)
|
|
91
|
+
|
|
92
|
+
const factoryData = await getAccountInitCode(owner, index)
|
|
90
93
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
+
if (entryPointVersion === "v0.6") {
|
|
95
|
+
return getSenderAddress<ENTRYPOINT_ADDRESS_V06_TYPE>(client, {
|
|
96
|
+
initCode: concatHex([factoryAddress, factoryData]),
|
|
97
|
+
entryPoint: entryPointAddress as ENTRYPOINT_ADDRESS_V06_TYPE
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Get the sender address based on the init code
|
|
102
|
+
return getSenderAddress<ENTRYPOINT_ADDRESS_V07_TYPE>(client, {
|
|
103
|
+
factory: factoryAddress,
|
|
104
|
+
factoryData,
|
|
105
|
+
entryPoint: entryPointAddress as ENTRYPOINT_ADDRESS_V07_TYPE
|
|
94
106
|
})
|
|
95
107
|
}
|
|
96
108
|
|
|
97
109
|
export type SignerToSimpleSmartAccountParameters<
|
|
110
|
+
entryPoint extends EntryPoint,
|
|
98
111
|
TSource extends string = "custom",
|
|
99
112
|
TAddress extends Address = Address
|
|
100
113
|
> = Prettify<{
|
|
101
114
|
signer: SmartAccountSigner<TSource, TAddress>
|
|
102
115
|
factoryAddress: Address
|
|
103
|
-
entryPoint:
|
|
116
|
+
entryPoint: entryPoint
|
|
104
117
|
index?: bigint
|
|
105
118
|
address?: Address
|
|
106
119
|
}>
|
|
@@ -111,6 +124,7 @@ export type SignerToSimpleSmartAccountParameters<
|
|
|
111
124
|
* @returns A Private Key Simple Account.
|
|
112
125
|
*/
|
|
113
126
|
export async function signerToSimpleSmartAccount<
|
|
127
|
+
entryPoint extends EntryPoint,
|
|
114
128
|
TTransport extends Transport = Transport,
|
|
115
129
|
TChain extends Chain | undefined = Chain | undefined,
|
|
116
130
|
TSource extends string = "custom",
|
|
@@ -120,11 +134,11 @@ export async function signerToSimpleSmartAccount<
|
|
|
120
134
|
{
|
|
121
135
|
signer,
|
|
122
136
|
factoryAddress,
|
|
123
|
-
entryPoint,
|
|
137
|
+
entryPoint: entryPointAddress,
|
|
124
138
|
index = 0n,
|
|
125
139
|
address
|
|
126
|
-
}: SignerToSimpleSmartAccountParameters<TSource, TAddress>
|
|
127
|
-
): Promise<SimpleSmartAccount<TTransport, TChain>> {
|
|
140
|
+
}: SignerToSimpleSmartAccountParameters<entryPoint, TSource, TAddress>
|
|
141
|
+
): Promise<SimpleSmartAccount<entryPoint, TTransport, TChain>> {
|
|
128
142
|
const viemSigner: LocalAccount = {
|
|
129
143
|
...signer,
|
|
130
144
|
signTransaction: (_, __) => {
|
|
@@ -134,10 +148,10 @@ export async function signerToSimpleSmartAccount<
|
|
|
134
148
|
|
|
135
149
|
const [accountAddress, chainId] = await Promise.all([
|
|
136
150
|
address ??
|
|
137
|
-
getAccountAddress<TTransport, TChain>({
|
|
151
|
+
getAccountAddress<entryPoint, TTransport, TChain>({
|
|
138
152
|
client,
|
|
139
153
|
factoryAddress,
|
|
140
|
-
entryPoint,
|
|
154
|
+
entryPoint: entryPointAddress,
|
|
141
155
|
owner: viemSigner.address,
|
|
142
156
|
index
|
|
143
157
|
}),
|
|
@@ -179,12 +193,12 @@ export async function signerToSimpleSmartAccount<
|
|
|
179
193
|
...account,
|
|
180
194
|
client: client,
|
|
181
195
|
publicKey: accountAddress,
|
|
182
|
-
entryPoint:
|
|
196
|
+
entryPoint: entryPointAddress,
|
|
183
197
|
source: "SimpleSmartAccount",
|
|
184
198
|
async getNonce() {
|
|
185
199
|
return getAccountNonce(client, {
|
|
186
200
|
sender: accountAddress,
|
|
187
|
-
entryPoint:
|
|
201
|
+
entryPoint: entryPointAddress
|
|
188
202
|
})
|
|
189
203
|
},
|
|
190
204
|
async signUserOperation(userOperation) {
|
|
@@ -192,7 +206,7 @@ export async function signerToSimpleSmartAccount<
|
|
|
192
206
|
message: {
|
|
193
207
|
raw: getUserOperationHash({
|
|
194
208
|
userOperation,
|
|
195
|
-
entryPoint:
|
|
209
|
+
entryPoint: entryPointAddress,
|
|
196
210
|
chainId: chainId
|
|
197
211
|
})
|
|
198
212
|
}
|
|
@@ -208,7 +222,28 @@ export async function signerToSimpleSmartAccount<
|
|
|
208
222
|
|
|
209
223
|
if (smartAccountDeployed) return "0x"
|
|
210
224
|
|
|
211
|
-
return
|
|
225
|
+
return concatHex([
|
|
226
|
+
factoryAddress,
|
|
227
|
+
await getAccountInitCode(viemSigner.address, index)
|
|
228
|
+
])
|
|
229
|
+
},
|
|
230
|
+
async getFactory() {
|
|
231
|
+
if (smartAccountDeployed) return undefined
|
|
232
|
+
smartAccountDeployed = await isSmartAccountDeployed(
|
|
233
|
+
client,
|
|
234
|
+
accountAddress
|
|
235
|
+
)
|
|
236
|
+
if (smartAccountDeployed) return undefined
|
|
237
|
+
return factoryAddress
|
|
238
|
+
},
|
|
239
|
+
async getFactoryData() {
|
|
240
|
+
if (smartAccountDeployed) return undefined
|
|
241
|
+
smartAccountDeployed = await isSmartAccountDeployed(
|
|
242
|
+
client,
|
|
243
|
+
accountAddress
|
|
244
|
+
)
|
|
245
|
+
if (smartAccountDeployed) return undefined
|
|
246
|
+
return getAccountInitCode(viemSigner.address, index)
|
|
212
247
|
},
|
|
213
248
|
async encodeDeployCallData(_) {
|
|
214
249
|
throw new Error("Simple account doesn't support account deployment")
|
|
@@ -220,6 +255,36 @@ export async function signerToSimpleSmartAccount<
|
|
|
220
255
|
value: bigint
|
|
221
256
|
data: Hex
|
|
222
257
|
}[]
|
|
258
|
+
|
|
259
|
+
if (getEntryPointVersion(entryPointAddress) === "v0.6") {
|
|
260
|
+
return encodeFunctionData({
|
|
261
|
+
abi: [
|
|
262
|
+
{
|
|
263
|
+
inputs: [
|
|
264
|
+
{
|
|
265
|
+
internalType: "address[]",
|
|
266
|
+
name: "dest",
|
|
267
|
+
type: "address[]"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
internalType: "bytes[]",
|
|
271
|
+
name: "func",
|
|
272
|
+
type: "bytes[]"
|
|
273
|
+
}
|
|
274
|
+
],
|
|
275
|
+
name: "executeBatch",
|
|
276
|
+
outputs: [],
|
|
277
|
+
stateMutability: "nonpayable",
|
|
278
|
+
type: "function"
|
|
279
|
+
}
|
|
280
|
+
],
|
|
281
|
+
functionName: "executeBatch",
|
|
282
|
+
args: [
|
|
283
|
+
argsArray.map((a) => a.to),
|
|
284
|
+
argsArray.map((a) => a.data)
|
|
285
|
+
]
|
|
286
|
+
})
|
|
287
|
+
}
|
|
223
288
|
return encodeFunctionData({
|
|
224
289
|
abi: [
|
|
225
290
|
{
|
|
@@ -229,6 +294,11 @@ export async function signerToSimpleSmartAccount<
|
|
|
229
294
|
name: "dest",
|
|
230
295
|
type: "address[]"
|
|
231
296
|
},
|
|
297
|
+
{
|
|
298
|
+
internalType: "uint256[]",
|
|
299
|
+
name: "value",
|
|
300
|
+
type: "uint256[]"
|
|
301
|
+
},
|
|
232
302
|
{
|
|
233
303
|
internalType: "bytes[]",
|
|
234
304
|
name: "func",
|
|
@@ -244,6 +314,7 @@ export async function signerToSimpleSmartAccount<
|
|
|
244
314
|
functionName: "executeBatch",
|
|
245
315
|
args: [
|
|
246
316
|
argsArray.map((a) => a.to),
|
|
317
|
+
argsArray.map((a) => a.value),
|
|
247
318
|
argsArray.map((a) => a.data)
|
|
248
319
|
]
|
|
249
320
|
})
|
package/accounts/types.ts
CHANGED
|
@@ -7,7 +7,8 @@ import {
|
|
|
7
7
|
type LocalAccount
|
|
8
8
|
} from "viem"
|
|
9
9
|
import type { Chain, EncodeDeployDataParameters, Transport } from "viem"
|
|
10
|
-
import {
|
|
10
|
+
import type { UserOperation } from "../types"
|
|
11
|
+
import type { EntryPoint, GetEntryPointVersion } from "../types/entrypoint"
|
|
11
12
|
|
|
12
13
|
export class SignTransactionNotSupportedBySmartAccount extends BaseError {
|
|
13
14
|
override name = "SignTransactionNotSupportedBySmartAccount"
|
|
@@ -26,15 +27,18 @@ export class SignTransactionNotSupportedBySmartAccount extends BaseError {
|
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
export type SmartAccount<
|
|
30
|
+
entryPoint extends EntryPoint,
|
|
29
31
|
Name extends string = string,
|
|
30
32
|
transport extends Transport = Transport,
|
|
31
33
|
chain extends Chain | undefined = Chain | undefined,
|
|
32
34
|
TAbi extends Abi | readonly unknown[] = Abi
|
|
33
35
|
> = LocalAccount<Name> & {
|
|
34
36
|
client: Client<transport, chain>
|
|
35
|
-
entryPoint:
|
|
37
|
+
entryPoint: entryPoint
|
|
36
38
|
getNonce: () => Promise<bigint>
|
|
37
39
|
getInitCode: () => Promise<Hex>
|
|
40
|
+
getFactory: () => Promise<Address | undefined>
|
|
41
|
+
getFactoryData: () => Promise<Hex | undefined>
|
|
38
42
|
encodeCallData: (
|
|
39
43
|
args:
|
|
40
44
|
| {
|
|
@@ -48,13 +52,17 @@ export type SmartAccount<
|
|
|
48
52
|
data: Hex
|
|
49
53
|
}[]
|
|
50
54
|
) => Promise<Hex>
|
|
51
|
-
getDummySignature(
|
|
55
|
+
getDummySignature(
|
|
56
|
+
userOperation: UserOperation<GetEntryPointVersion<entryPoint>>
|
|
57
|
+
): Promise<Hex>
|
|
52
58
|
encodeDeployCallData: ({
|
|
53
59
|
abi,
|
|
54
60
|
args,
|
|
55
61
|
bytecode
|
|
56
62
|
}: EncodeDeployDataParameters<TAbi>) => Promise<Hex>
|
|
57
|
-
signUserOperation: (
|
|
63
|
+
signUserOperation: (
|
|
64
|
+
userOperation: UserOperation<GetEntryPointVersion<entryPoint>>
|
|
65
|
+
) => Promise<Hex>
|
|
58
66
|
}
|
|
59
67
|
|
|
60
68
|
export type SmartAccountSigner<
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Account, Chain, Client, Transport } from "viem"
|
|
2
2
|
import type { BundlerClient } from "../../clients/createBundlerClient"
|
|
3
|
+
import type { EntryPoint } from "../../types"
|
|
3
4
|
import type { BundlerRpcSchema } from "../../types/bundler"
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -25,11 +26,12 @@ import type { BundlerRpcSchema } from "../../types/bundler"
|
|
|
25
26
|
*
|
|
26
27
|
*/
|
|
27
28
|
export const chainId = async <
|
|
29
|
+
entryPoint extends EntryPoint,
|
|
28
30
|
TTransport extends Transport = Transport,
|
|
29
31
|
TChain extends Chain | undefined = Chain | undefined,
|
|
30
32
|
TAccount extends Account | undefined = Account | undefined
|
|
31
33
|
>(
|
|
32
|
-
client: Client<TTransport, TChain, TAccount, BundlerRpcSchema
|
|
34
|
+
client: Client<TTransport, TChain, TAccount, BundlerRpcSchema<entryPoint>>
|
|
33
35
|
) => {
|
|
34
36
|
return Number(
|
|
35
37
|
await client.request({
|
|
@@ -1,38 +1,59 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type Account,
|
|
3
|
-
type Address,
|
|
4
3
|
BaseError,
|
|
5
4
|
type Chain,
|
|
6
5
|
type Client,
|
|
6
|
+
type Hex,
|
|
7
7
|
type Transport
|
|
8
8
|
} from "viem"
|
|
9
9
|
import type { PartialBy } from "viem/types/utils"
|
|
10
10
|
import type { BundlerClient } from "../../clients/createBundlerClient"
|
|
11
11
|
import type { Prettify } from "../../types/"
|
|
12
12
|
import type { BundlerRpcSchema, StateOverrides } from "../../types/bundler"
|
|
13
|
+
import type { EntryPoint, GetEntryPointVersion } from "../../types/entrypoint"
|
|
13
14
|
import type { UserOperation } from "../../types/userOperation"
|
|
15
|
+
import { getEntryPointVersion } from "../../utils"
|
|
14
16
|
import { deepHexlify } from "../../utils/deepHexlify"
|
|
15
17
|
import {
|
|
16
18
|
type GetEstimateUserOperationGasErrorReturnType,
|
|
17
19
|
getEstimateUserOperationGasError
|
|
18
20
|
} from "../../utils/errors/getEstimateUserOperationGasError"
|
|
19
21
|
|
|
20
|
-
export type EstimateUserOperationGasParameters =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
export type EstimateUserOperationGasParameters<entryPoint extends EntryPoint> =
|
|
23
|
+
{
|
|
24
|
+
userOperation: GetEntryPointVersion<entryPoint> extends "v0.6"
|
|
25
|
+
? PartialBy<
|
|
26
|
+
UserOperation<"v0.6">,
|
|
27
|
+
"callGasLimit" | "preVerificationGas" | "verificationGasLimit"
|
|
28
|
+
>
|
|
29
|
+
: PartialBy<
|
|
30
|
+
UserOperation<"v0.7">,
|
|
31
|
+
| "callGasLimit"
|
|
32
|
+
| "preVerificationGas"
|
|
33
|
+
| "verificationGasLimit"
|
|
34
|
+
| "paymasterVerificationGasLimit"
|
|
35
|
+
| "paymasterPostOpGasLimit"
|
|
36
|
+
>
|
|
37
|
+
entryPoint: entryPoint
|
|
38
|
+
}
|
|
27
39
|
|
|
28
|
-
export type EstimateUserOperationGasReturnType =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
40
|
+
export type EstimateUserOperationGasReturnType<entryPoint extends EntryPoint> =
|
|
41
|
+
GetEntryPointVersion<entryPoint> extends "v0.6"
|
|
42
|
+
? {
|
|
43
|
+
preVerificationGas: bigint
|
|
44
|
+
verificationGasLimit: bigint
|
|
45
|
+
callGasLimit: bigint
|
|
46
|
+
}
|
|
47
|
+
: {
|
|
48
|
+
preVerificationGas: bigint
|
|
49
|
+
verificationGasLimit: bigint
|
|
50
|
+
callGasLimit: bigint
|
|
51
|
+
paymasterVerificationGasLimit: bigint | undefined
|
|
52
|
+
paymasterPostOpGasLimit: bigint | undefined
|
|
53
|
+
}
|
|
33
54
|
|
|
34
|
-
export type EstimateUserOperationErrorType =
|
|
35
|
-
GetEstimateUserOperationGasErrorReturnType
|
|
55
|
+
export type EstimateUserOperationErrorType<entryPoint extends EntryPoint> =
|
|
56
|
+
GetEstimateUserOperationGasErrorReturnType<entryPoint>
|
|
36
57
|
|
|
37
58
|
/**
|
|
38
59
|
* Estimates preVerificationGas, verificationGasLimit and callGasLimit for user operation
|
|
@@ -62,14 +83,15 @@ export type EstimateUserOperationErrorType =
|
|
|
62
83
|
*
|
|
63
84
|
*/
|
|
64
85
|
export const estimateUserOperationGas = async <
|
|
86
|
+
entryPoint extends EntryPoint,
|
|
65
87
|
TTransport extends Transport = Transport,
|
|
66
88
|
TChain extends Chain | undefined = Chain | undefined,
|
|
67
89
|
TAccount extends Account | undefined = Account | undefined
|
|
68
90
|
>(
|
|
69
|
-
client: Client<TTransport, TChain, TAccount, BundlerRpcSchema
|
|
70
|
-
args: Prettify<EstimateUserOperationGasParameters
|
|
91
|
+
client: Client<TTransport, TChain, TAccount, BundlerRpcSchema<entryPoint>>,
|
|
92
|
+
args: Prettify<EstimateUserOperationGasParameters<entryPoint>>,
|
|
71
93
|
stateOverrides?: StateOverrides
|
|
72
|
-
): Promise<
|
|
94
|
+
): Promise<EstimateUserOperationGasReturnType<entryPoint>> => {
|
|
73
95
|
const { userOperation, entryPoint } = args
|
|
74
96
|
|
|
75
97
|
const userOperationWithBigIntAsHex = deepHexlify(userOperation)
|
|
@@ -87,11 +109,44 @@ export const estimateUserOperationGas = async <
|
|
|
87
109
|
: [userOperationWithBigIntAsHex, entryPoint]
|
|
88
110
|
})
|
|
89
111
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
112
|
+
const entryPointVersion = getEntryPointVersion(entryPoint)
|
|
113
|
+
|
|
114
|
+
if (entryPointVersion === "v0.6") {
|
|
115
|
+
const responseV06 = response as {
|
|
116
|
+
preVerificationGas: Hex
|
|
117
|
+
verificationGasLimit: Hex
|
|
118
|
+
callGasLimit: Hex
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return {
|
|
122
|
+
preVerificationGas: BigInt(responseV06.preVerificationGas || 0),
|
|
123
|
+
verificationGasLimit: BigInt(
|
|
124
|
+
responseV06.verificationGasLimit || 0
|
|
125
|
+
),
|
|
126
|
+
callGasLimit: BigInt(responseV06.callGasLimit || 0)
|
|
127
|
+
} as EstimateUserOperationGasReturnType<entryPoint>
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const responseV07 = response as {
|
|
131
|
+
preVerificationGas: Hex
|
|
132
|
+
verificationGasLimit: Hex
|
|
133
|
+
callGasLimit: Hex
|
|
134
|
+
paymasterVerificationGasLimit: Hex | undefined
|
|
135
|
+
paymasterPostOpGasLimit: Hex | undefined
|
|
94
136
|
}
|
|
137
|
+
|
|
138
|
+
return {
|
|
139
|
+
preVerificationGas: BigInt(responseV07.preVerificationGas || 0),
|
|
140
|
+
verificationGasLimit: BigInt(responseV07.verificationGasLimit || 0),
|
|
141
|
+
callGasLimit: BigInt(responseV07.callGasLimit || 0),
|
|
142
|
+
paymasterVerificationGasLimit:
|
|
143
|
+
responseV07.paymasterVerificationGasLimit
|
|
144
|
+
? BigInt(responseV07.paymasterVerificationGasLimit)
|
|
145
|
+
: undefined,
|
|
146
|
+
paymasterPostOpGasLimit: responseV07.paymasterPostOpGasLimit
|
|
147
|
+
? BigInt(responseV07.paymasterPostOpGasLimit)
|
|
148
|
+
: undefined
|
|
149
|
+
} as EstimateUserOperationGasReturnType<entryPoint>
|
|
95
150
|
} catch (err) {
|
|
96
151
|
throw getEstimateUserOperationGasError(err as BaseError, args)
|
|
97
152
|
}
|
|
@@ -2,14 +2,16 @@ import type { Account, Address, Chain, Client, Hash, Transport } from "viem"
|
|
|
2
2
|
import type { BundlerClient } from "../../clients/createBundlerClient"
|
|
3
3
|
import type { Prettify } from "../../types/"
|
|
4
4
|
import type { BundlerRpcSchema } from "../../types/bundler"
|
|
5
|
+
import type { EntryPoint, GetEntryPointVersion } from "../../types/entrypoint"
|
|
5
6
|
import type { UserOperation } from "../../types/userOperation"
|
|
7
|
+
import { ENTRYPOINT_ADDRESS_V06 } from "../../utils/getEntryPointVersion"
|
|
6
8
|
|
|
7
9
|
export type GetUserOperationByHashParameters = {
|
|
8
10
|
hash: Hash
|
|
9
11
|
}
|
|
10
12
|
|
|
11
|
-
export type GetUserOperationByHashReturnType = {
|
|
12
|
-
userOperation: UserOperation
|
|
13
|
+
export type GetUserOperationByHashReturnType<entryPoint extends EntryPoint> = {
|
|
14
|
+
userOperation: UserOperation<GetEntryPointVersion<entryPoint>>
|
|
13
15
|
entryPoint: Address
|
|
14
16
|
transactionHash: Hash
|
|
15
17
|
blockHash: Hash
|
|
@@ -39,13 +41,14 @@ export type GetUserOperationByHashReturnType = {
|
|
|
39
41
|
*
|
|
40
42
|
*/
|
|
41
43
|
export const getUserOperationByHash = async <
|
|
44
|
+
entryPoint extends EntryPoint,
|
|
42
45
|
TTransport extends Transport = Transport,
|
|
43
46
|
TChain extends Chain | undefined = Chain | undefined,
|
|
44
47
|
TAccount extends Account | undefined = Account | undefined
|
|
45
48
|
>(
|
|
46
|
-
client: Client<TTransport, TChain, TAccount, BundlerRpcSchema
|
|
49
|
+
client: Client<TTransport, TChain, TAccount, BundlerRpcSchema<entryPoint>>,
|
|
47
50
|
{ hash }: Prettify<GetUserOperationByHashParameters>
|
|
48
|
-
): Promise<Prettify<GetUserOperationByHashReturnType
|
|
51
|
+
): Promise<Prettify<GetUserOperationByHashReturnType<entryPoint>> | null> => {
|
|
49
52
|
const params: [Hash] = [hash]
|
|
50
53
|
|
|
51
54
|
const response = await client.request({
|
|
@@ -57,23 +60,49 @@ export const getUserOperationByHash = async <
|
|
|
57
60
|
|
|
58
61
|
const {
|
|
59
62
|
userOperation,
|
|
60
|
-
entryPoint,
|
|
63
|
+
entryPoint: entryPointAddress,
|
|
61
64
|
transactionHash,
|
|
62
65
|
blockHash,
|
|
63
66
|
blockNumber
|
|
64
67
|
} = response
|
|
65
68
|
|
|
66
69
|
return {
|
|
67
|
-
userOperation:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
userOperation: (entryPointAddress === ENTRYPOINT_ADDRESS_V06
|
|
71
|
+
? {
|
|
72
|
+
...userOperation,
|
|
73
|
+
nonce: BigInt(userOperation.nonce),
|
|
74
|
+
callGasLimit: BigInt(userOperation.callGasLimit),
|
|
75
|
+
verificationGasLimit: BigInt(
|
|
76
|
+
userOperation.verificationGasLimit
|
|
77
|
+
),
|
|
78
|
+
preVerificationGas: BigInt(userOperation.preVerificationGas),
|
|
79
|
+
maxFeePerGas: BigInt(userOperation.maxFeePerGas),
|
|
80
|
+
maxPriorityFeePerGas: BigInt(
|
|
81
|
+
userOperation.maxPriorityFeePerGas
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
: {
|
|
85
|
+
...userOperation,
|
|
86
|
+
nonce: BigInt(userOperation.nonce),
|
|
87
|
+
callGasLimit: BigInt(userOperation.callGasLimit),
|
|
88
|
+
verificationGasLimit: BigInt(
|
|
89
|
+
userOperation.verificationGasLimit
|
|
90
|
+
),
|
|
91
|
+
preVerificationGas: BigInt(userOperation.preVerificationGas),
|
|
92
|
+
maxFeePerGas: BigInt(userOperation.maxFeePerGas),
|
|
93
|
+
maxPriorityFeePerGas: BigInt(
|
|
94
|
+
userOperation.maxPriorityFeePerGas
|
|
95
|
+
),
|
|
96
|
+
paymasterVerificationGasLimit:
|
|
97
|
+
userOperation.paymasterVerificationGasLimit
|
|
98
|
+
? BigInt(userOperation.paymasterVerificationGasLimit)
|
|
99
|
+
: undefined,
|
|
100
|
+
paymasterPostOpGasLimit:
|
|
101
|
+
userOperation.paymasterVerificationGasLimit
|
|
102
|
+
? BigInt(userOperation.paymasterPostOpGasLimit)
|
|
103
|
+
: undefined
|
|
104
|
+
}) as UserOperation<GetEntryPointVersion<entryPoint>>,
|
|
105
|
+
entryPoint: entryPointAddress,
|
|
77
106
|
transactionHash: transactionHash,
|
|
78
107
|
blockHash: blockHash,
|
|
79
108
|
blockNumber: BigInt(blockNumber)
|
|
@@ -10,6 +10,7 @@ import type {
|
|
|
10
10
|
import type { BundlerClient } from "../../clients/createBundlerClient"
|
|
11
11
|
import type { Prettify } from "../../types"
|
|
12
12
|
import type { BundlerRpcSchema } from "../../types/bundler"
|
|
13
|
+
import type { EntryPoint } from "../../types/entrypoint"
|
|
13
14
|
import type { TStatus } from "../../types/userOperation"
|
|
14
15
|
import { transactionReceiptStatus } from "../../utils/deepHexlify"
|
|
15
16
|
|
|
@@ -73,11 +74,12 @@ export type GetUserOperationReceiptReturnType = {
|
|
|
73
74
|
*
|
|
74
75
|
*/
|
|
75
76
|
export const getUserOperationReceipt = async <
|
|
77
|
+
entryPoint extends EntryPoint,
|
|
76
78
|
TTransport extends Transport = Transport,
|
|
77
79
|
TChain extends Chain | undefined = Chain | undefined,
|
|
78
80
|
TAccount extends Account | undefined = Account | undefined
|
|
79
81
|
>(
|
|
80
|
-
client: Client<TTransport, TChain, TAccount, BundlerRpcSchema
|
|
82
|
+
client: Client<TTransport, TChain, TAccount, BundlerRpcSchema<entryPoint>>,
|
|
81
83
|
{ hash }: Prettify<GetUserOperationReceiptParameters>
|
|
82
84
|
): Promise<Prettify<GetUserOperationReceiptReturnType> | null> => {
|
|
83
85
|
const params: [Hash] = [hash]
|