permissionless 0.0.11 → 0.0.13
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 +16 -0
- package/_cjs/accounts/index.js +14 -0
- package/_cjs/accounts/index.js.map +1 -0
- package/_cjs/accounts/privateKeyToSafeSmartAccount.js +24 -0
- package/_cjs/accounts/privateKeyToSafeSmartAccount.js.map +1 -0
- package/_cjs/accounts/privateKeyToSimpleSmartAccount.js +16 -0
- package/_cjs/accounts/privateKeyToSimpleSmartAccount.js.map +1 -0
- package/_cjs/accounts/signerToSafeSmartAccount.js +492 -0
- package/_cjs/accounts/signerToSafeSmartAccount.js.map +1 -0
- package/_cjs/accounts/signerToSimpleSmartAccount.js +190 -0
- package/_cjs/accounts/signerToSimpleSmartAccount.js.map +1 -0
- package/_cjs/accounts/types.js +23 -0
- package/_cjs/accounts/types.js.map +1 -0
- package/_cjs/actions/bundler/chainId.js.map +1 -1
- package/_cjs/actions/bundler/estimateUserOperationGas.js +4 -1
- package/_cjs/actions/bundler/estimateUserOperationGas.js.map +1 -1
- package/_cjs/actions/bundler/getUserOperationByHash.js.map +1 -1
- package/_cjs/actions/bundler/getUserOperationReceipt.js.map +1 -1
- package/_cjs/actions/bundler/sendUserOperation.js +4 -1
- package/_cjs/actions/bundler/sendUserOperation.js.map +1 -1
- package/_cjs/actions/bundler/supportedEntryPoints.js.map +1 -1
- package/_cjs/actions/bundler/waitForUserOperationReceipt.js +7 -2
- package/_cjs/actions/bundler/waitForUserOperationReceipt.js.map +1 -1
- package/_cjs/actions/index.js.map +1 -1
- package/_cjs/actions/pimlico/getUserOperationGasPrice.js.map +1 -1
- package/_cjs/actions/pimlico/getUserOperationStatus.js.map +1 -1
- package/_cjs/actions/pimlico/sponsorUserOperation.js +4 -1
- package/_cjs/actions/pimlico/sponsorUserOperation.js.map +1 -1
- package/_cjs/actions/pimlico.js.map +1 -1
- package/_cjs/actions/public/getAccountNonce.js +4 -2
- package/_cjs/actions/public/getAccountNonce.js.map +1 -1
- package/_cjs/actions/public/getSenderAddress.js +7 -3
- package/_cjs/actions/public/getSenderAddress.js.map +1 -1
- package/_cjs/actions/smartAccount/deployContract.js +38 -0
- package/_cjs/actions/smartAccount/deployContract.js.map +1 -0
- package/_cjs/actions/smartAccount/prepareUserOperationRequest.js +73 -0
- package/_cjs/actions/smartAccount/prepareUserOperationRequest.js.map +1 -0
- package/_cjs/actions/smartAccount/sendTransaction.js +44 -0
- package/_cjs/actions/smartAccount/sendTransaction.js.map +1 -0
- package/_cjs/actions/smartAccount/sendTransactions.js +46 -0
- package/_cjs/actions/smartAccount/sendTransactions.js.map +1 -0
- package/_cjs/actions/smartAccount/sendUserOperation.js +22 -0
- package/_cjs/actions/smartAccount/sendUserOperation.js.map +1 -0
- package/_cjs/actions/smartAccount/signMessage.js +16 -0
- package/_cjs/actions/smartAccount/signMessage.js.map +1 -0
- package/_cjs/actions/smartAccount/signTypedData.js +34 -0
- package/_cjs/actions/smartAccount/signTypedData.js.map +1 -0
- package/_cjs/actions/smartAccount/writeContract.js +21 -0
- package/_cjs/actions/smartAccount/writeContract.js.map +1 -0
- package/_cjs/actions/smartAccount.js +18 -0
- package/_cjs/actions/smartAccount.js.map +1 -0
- package/_cjs/actions/stackup/sponsorUserOperation.js +5 -1
- package/_cjs/actions/stackup/sponsorUserOperation.js.map +1 -1
- package/_cjs/clients/{bundler.js → createBundlerClient.js} +1 -1
- package/_cjs/clients/createBundlerClient.js.map +1 -0
- package/_cjs/clients/createSmartAccountClient.js +20 -0
- package/_cjs/clients/createSmartAccountClient.js.map +1 -0
- package/_cjs/clients/decorators/bundler.js.map +1 -1
- package/_cjs/clients/decorators/pimlico.js.map +1 -1
- package/_cjs/clients/decorators/smartAccount.js +33 -0
- package/_cjs/clients/decorators/smartAccount.js.map +1 -0
- package/_cjs/clients/decorators/stackup.js.map +1 -1
- package/_cjs/clients/pimlico.js.map +1 -1
- package/_cjs/clients/stackup.js.map +1 -1
- package/_cjs/index.js +9 -5
- package/_cjs/index.js.map +1 -1
- package/_cjs/utils/deepHexlify.js +4 -4
- package/_cjs/utils/deepHexlify.js.map +1 -1
- package/_cjs/utils/getAction.js +8 -0
- package/_cjs/utils/getAction.js.map +1 -0
- package/_cjs/utils/getUserOperationHash.js.map +1 -1
- package/_cjs/utils/index.js +7 -1
- package/_cjs/utils/index.js.map +1 -1
- package/_cjs/utils/observe.js +7 -2
- package/_cjs/utils/observe.js.map +1 -1
- package/_cjs/utils/signUserOperationHashWithECDSA.js +7 -7
- package/_cjs/utils/signUserOperationHashWithECDSA.js.map +1 -1
- package/_esm/accounts/index.js +7 -0
- package/_esm/accounts/index.js.map +1 -0
- package/_esm/accounts/privateKeyToSafeSmartAccount.js +26 -0
- package/_esm/accounts/privateKeyToSafeSmartAccount.js.map +1 -0
- package/_esm/accounts/privateKeyToSimpleSmartAccount.js +18 -0
- package/_esm/accounts/privateKeyToSimpleSmartAccount.js.map +1 -0
- package/_esm/accounts/signerToSafeSmartAccount.js +499 -0
- package/_esm/accounts/signerToSafeSmartAccount.js.map +1 -0
- package/_esm/accounts/signerToSimpleSmartAccount.js +191 -0
- package/_esm/accounts/signerToSimpleSmartAccount.js.map +1 -0
- package/_esm/accounts/types.js +20 -0
- package/_esm/accounts/types.js.map +1 -0
- package/_esm/actions/bundler/chainId.js.map +1 -1
- package/_esm/actions/bundler/estimateUserOperationGas.js +4 -1
- package/_esm/actions/bundler/estimateUserOperationGas.js.map +1 -1
- package/_esm/actions/bundler/getUserOperationByHash.js.map +1 -1
- package/_esm/actions/bundler/getUserOperationReceipt.js.map +1 -1
- package/_esm/actions/bundler/sendUserOperation.js +4 -3
- package/_esm/actions/bundler/sendUserOperation.js.map +1 -1
- package/_esm/actions/bundler/supportedEntryPoints.js.map +1 -1
- package/_esm/actions/bundler/waitForUserOperationReceipt.js +7 -2
- package/_esm/actions/bundler/waitForUserOperationReceipt.js.map +1 -1
- package/_esm/actions/index.js.map +1 -1
- package/_esm/actions/pimlico/getUserOperationGasPrice.js +2 -2
- package/_esm/actions/pimlico/getUserOperationGasPrice.js.map +1 -1
- package/_esm/actions/pimlico/getUserOperationStatus.js +1 -1
- package/_esm/actions/pimlico/getUserOperationStatus.js.map +1 -1
- package/_esm/actions/pimlico/sponsorUserOperation.js +4 -1
- package/_esm/actions/pimlico/sponsorUserOperation.js.map +1 -1
- package/_esm/actions/pimlico.js.map +1 -1
- package/_esm/actions/public/getAccountNonce.js +7 -5
- package/_esm/actions/public/getAccountNonce.js.map +1 -1
- package/_esm/actions/public/getSenderAddress.js +8 -5
- package/_esm/actions/public/getSenderAddress.js.map +1 -1
- package/_esm/actions/smartAccount/deployContract.js +64 -0
- package/_esm/actions/smartAccount/deployContract.js.map +1 -0
- package/_esm/actions/smartAccount/prepareUserOperationRequest.js +69 -0
- package/_esm/actions/smartAccount/prepareUserOperationRequest.js.map +1 -0
- package/_esm/actions/smartAccount/sendTransaction.js +88 -0
- package/_esm/actions/smartAccount/sendTransaction.js.map +1 -0
- package/_esm/actions/smartAccount/sendTransactions.js +90 -0
- package/_esm/actions/smartAccount/sendTransactions.js.map +1 -0
- package/_esm/actions/smartAccount/sendUserOperation.js +18 -0
- package/_esm/actions/smartAccount/sendUserOperation.js.map +1 -0
- package/_esm/actions/smartAccount/signMessage.js +59 -0
- package/_esm/actions/smartAccount/signMessage.js.map +1 -0
- package/_esm/actions/smartAccount/signTypedData.js +129 -0
- package/_esm/actions/smartAccount/signTypedData.js.map +1 -0
- package/_esm/actions/smartAccount/writeContract.js +19 -0
- package/_esm/actions/smartAccount/writeContract.js.map +1 -0
- package/_esm/actions/smartAccount.js +9 -0
- package/_esm/actions/smartAccount.js.map +1 -0
- package/_esm/actions/stackup/accounts.js +1 -1
- package/_esm/actions/stackup/sponsorUserOperation.js +6 -2
- package/_esm/actions/stackup/sponsorUserOperation.js.map +1 -1
- package/_esm/clients/{bundler.js → createBundlerClient.js} +1 -1
- package/_esm/clients/createBundlerClient.js.map +1 -0
- package/_esm/clients/createSmartAccountClient.js +38 -0
- package/_esm/clients/createSmartAccountClient.js.map +1 -0
- package/_esm/clients/decorators/bundler.js.map +1 -1
- package/_esm/clients/decorators/pimlico.js +1 -1
- package/_esm/clients/decorators/pimlico.js.map +1 -1
- package/_esm/clients/decorators/smartAccount.js +29 -0
- package/_esm/clients/decorators/smartAccount.js.map +1 -0
- package/_esm/clients/decorators/stackup.js.map +1 -1
- package/_esm/clients/pimlico.js +1 -1
- package/_esm/clients/pimlico.js.map +1 -1
- package/_esm/clients/stackup.js +1 -1
- package/_esm/clients/stackup.js.map +1 -1
- package/_esm/index.js +5 -2
- package/_esm/index.js.map +1 -1
- package/_esm/utils/deepHexlify.js +6 -4
- package/_esm/utils/deepHexlify.js.map +1 -1
- package/_esm/utils/getAction.js +6 -0
- package/_esm/utils/getAction.js.map +1 -0
- package/_esm/utils/getUserOperationHash.js.map +1 -1
- package/_esm/utils/index.js +5 -0
- package/_esm/utils/index.js.map +1 -1
- package/_esm/utils/observe.js +7 -2
- package/_esm/utils/observe.js.map +1 -1
- package/_esm/utils/signUserOperationHashWithECDSA.js +7 -6
- package/_esm/utils/signUserOperationHashWithECDSA.js.map +1 -1
- package/_types/accounts/index.d.ts +7 -0
- package/_types/accounts/index.d.ts.map +1 -0
- package/_types/accounts/privateKeyToSafeSmartAccount.d.ts +26 -0
- package/_types/accounts/privateKeyToSafeSmartAccount.d.ts.map +1 -0
- package/_types/accounts/privateKeyToSimpleSmartAccount.d.ts +14 -0
- package/_types/accounts/privateKeyToSimpleSmartAccount.d.ts.map +1 -0
- package/_types/accounts/signerToSafeSmartAccount.d.ts +28 -0
- package/_types/accounts/signerToSafeSmartAccount.d.ts.map +1 -0
- package/_types/accounts/signerToSimpleSmartAccount.d.ts +15 -0
- package/_types/accounts/signerToSimpleSmartAccount.d.ts.map +1 -0
- package/_types/accounts/types.d.ts +32 -0
- package/_types/accounts/types.d.ts.map +1 -0
- package/_types/actions/bundler/chainId.d.ts +3 -2
- package/_types/actions/bundler/chainId.d.ts.map +1 -1
- package/_types/actions/bundler/estimateUserOperationGas.d.ts +3 -3
- package/_types/actions/bundler/estimateUserOperationGas.d.ts.map +1 -1
- package/_types/actions/bundler/getUserOperationByHash.d.ts +3 -3
- package/_types/actions/bundler/getUserOperationByHash.d.ts.map +1 -1
- package/_types/actions/bundler/getUserOperationReceipt.d.ts +3 -3
- package/_types/actions/bundler/getUserOperationReceipt.d.ts.map +1 -1
- package/_types/actions/bundler/sendUserOperation.d.ts +3 -5
- package/_types/actions/bundler/sendUserOperation.d.ts.map +1 -1
- package/_types/actions/bundler/supportedEntryPoints.d.ts +3 -3
- package/_types/actions/bundler/supportedEntryPoints.d.ts.map +1 -1
- package/_types/actions/bundler/waitForUserOperationReceipt.d.ts +2 -3
- package/_types/actions/bundler/waitForUserOperationReceipt.d.ts.map +1 -1
- package/_types/actions/index.d.ts.map +1 -1
- package/_types/actions/pimlico/getUserOperationGasPrice.d.ts +5 -4
- package/_types/actions/pimlico/getUserOperationGasPrice.d.ts.map +1 -1
- package/_types/actions/pimlico/getUserOperationStatus.d.ts +4 -5
- package/_types/actions/pimlico/getUserOperationStatus.d.ts.map +1 -1
- package/_types/actions/pimlico/sponsorUserOperation.d.ts +3 -3
- package/_types/actions/pimlico/sponsorUserOperation.d.ts.map +1 -1
- package/_types/actions/pimlico.d.ts.map +1 -1
- package/_types/actions/public/getAccountNonce.d.ts +5 -5
- package/_types/actions/public/getAccountNonce.d.ts.map +1 -1
- package/_types/actions/public/getSenderAddress.d.ts +3 -4
- package/_types/actions/public/getSenderAddress.d.ts.map +1 -1
- package/_types/actions/smartAccount/deployContract.d.ts +34 -0
- package/_types/actions/smartAccount/deployContract.d.ts.map +1 -0
- package/_types/actions/smartAccount/prepareUserOperationRequest.d.ts +20 -0
- package/_types/actions/smartAccount/prepareUserOperationRequest.d.ts.map +1 -0
- package/_types/actions/smartAccount/sendTransaction.d.ts +52 -0
- package/_types/actions/smartAccount/sendTransaction.d.ts.map +1 -0
- package/_types/actions/smartAccount/sendTransactions.d.ts +63 -0
- package/_types/actions/smartAccount/sendTransactions.d.ts.map +1 -0
- package/_types/actions/smartAccount/sendUserOperation.d.ts +10 -0
- package/_types/actions/smartAccount/sendUserOperation.d.ts.map +1 -0
- package/_types/actions/smartAccount/signMessage.d.ts +50 -0
- package/_types/actions/smartAccount/signMessage.d.ts.map +1 -0
- package/_types/actions/smartAccount/signTypedData.d.ts +104 -0
- package/_types/actions/smartAccount/signTypedData.d.ts.map +1 -0
- package/_types/actions/smartAccount/writeContract.d.ts +57 -0
- package/_types/actions/smartAccount/writeContract.d.ts.map +1 -0
- package/_types/actions/smartAccount.d.ts +9 -0
- package/_types/actions/smartAccount.d.ts.map +1 -0
- package/_types/actions/stackup/accounts.d.ts +1 -1
- package/_types/actions/stackup/sponsorUserOperation.d.ts +1 -1
- package/_types/actions/stackup/sponsorUserOperation.d.ts.map +1 -1
- package/_types/clients/{bundler.d.ts → createBundlerClient.d.ts} +1 -1
- package/_types/clients/createBundlerClient.d.ts.map +1 -0
- package/_types/clients/createSmartAccountClient.d.ts +282 -0
- package/_types/clients/createSmartAccountClient.d.ts.map +1 -0
- package/_types/clients/decorators/bundler.d.ts +1 -1
- package/_types/clients/decorators/bundler.d.ts.map +1 -1
- package/_types/clients/decorators/pimlico.d.ts +3 -3
- package/_types/clients/decorators/pimlico.d.ts.map +1 -1
- package/_types/clients/decorators/smartAccount.d.ts +327 -0
- package/_types/clients/decorators/smartAccount.d.ts.map +1 -0
- package/_types/clients/decorators/stackup.d.ts.map +1 -1
- package/_types/clients/pimlico.d.ts +1 -1
- package/_types/clients/pimlico.d.ts.map +1 -1
- package/_types/clients/stackup.d.ts +1 -1
- package/_types/clients/stackup.d.ts.map +1 -1
- package/_types/index.d.ts +6 -3
- package/_types/index.d.ts.map +1 -1
- package/_types/types/bundler.d.ts +4 -1
- package/_types/types/bundler.d.ts.map +1 -1
- package/_types/types/index.d.ts +20 -0
- package/_types/types/index.d.ts.map +1 -1
- package/_types/types/pimlico.d.ts.map +1 -1
- package/_types/types/stackup.d.ts.map +1 -1
- package/_types/utils/deepHexlify.d.ts.map +1 -1
- package/_types/utils/getAction.d.ts +3 -0
- package/_types/utils/getAction.d.ts.map +1 -0
- package/_types/utils/getUserOperationHash.d.ts.map +1 -1
- package/_types/utils/index.d.ts +2 -0
- package/_types/utils/index.d.ts.map +1 -1
- package/_types/utils/observe.d.ts.map +1 -1
- package/_types/utils/signUserOperationHashWithECDSA.d.ts +3 -11
- package/_types/utils/signUserOperationHashWithECDSA.d.ts.map +1 -1
- package/accounts/index.ts +33 -0
- package/accounts/privateKeyToSafeSmartAccount.ts +73 -0
- package/accounts/privateKeyToSimpleSmartAccount.ts +44 -0
- package/accounts/signerToSafeSmartAccount.ts +775 -0
- package/accounts/signerToSimpleSmartAccount.ts +267 -0
- package/accounts/types.ts +64 -0
- package/actions/bundler/chainId.ts +10 -2
- package/actions/bundler/estimateUserOperationGas.ts +17 -6
- package/actions/bundler/getUserOperationByHash.ts +16 -5
- package/actions/bundler/getUserOperationReceipt.ts +17 -4
- package/actions/bundler/sendUserOperation.ts +19 -7
- package/actions/bundler/supportedEntryPoints.ts +10 -3
- package/actions/bundler/waitForUserOperationReceipt.ts +64 -26
- package/actions/index.ts +4 -1
- package/actions/pimlico/getUserOperationGasPrice.ts +13 -6
- package/actions/pimlico/getUserOperationStatus.ts +12 -5
- package/actions/pimlico/sponsorUserOperation.ts +20 -7
- package/actions/pimlico.ts +8 -2
- package/actions/public/getAccountNonce.ts +20 -8
- package/actions/public/getSenderAddress.ts +25 -8
- package/actions/smartAccount/deployContract.ts +110 -0
- package/actions/smartAccount/prepareUserOperationRequest.ts +140 -0
- package/actions/smartAccount/sendTransaction.ts +138 -0
- package/actions/smartAccount/sendTransactions.ts +141 -0
- package/actions/smartAccount/sendUserOperation.ts +70 -0
- package/actions/smartAccount/signMessage.ts +79 -0
- package/actions/smartAccount/signTypedData.ts +161 -0
- package/actions/smartAccount/writeContract.ts +126 -0
- package/actions/smartAccount.ts +49 -0
- package/actions/stackup/accounts.ts +1 -1
- package/actions/stackup/sponsorUserOperation.ts +14 -4
- package/clients/{bundler.ts → createBundlerClient.ts} +14 -3
- package/clients/createSmartAccountClient.ts +95 -0
- package/clients/decorators/bundler.ts +20 -10
- package/clients/decorators/pimlico.ts +21 -9
- package/clients/decorators/smartAccount.ts +451 -0
- package/clients/decorators/stackup.ts +12 -4
- package/clients/pimlico.ts +20 -5
- package/clients/stackup.ts +17 -4
- package/index.ts +20 -3
- package/package.json +12 -2
- package/types/bundler.ts +4 -1
- package/types/index.ts +29 -0
- package/types/pimlico.ts +12 -2
- package/types/stackup.ts +4 -1
- package/utils/deepHexlify.test.ts +13 -7
- package/utils/deepHexlify.ts +5 -4
- package/utils/getAction.ts +15 -0
- package/utils/getUserOperationHash.ts +10 -2
- package/utils/index.ts +15 -2
- package/utils/observe.ts +18 -5
- package/utils/signUserOperationHashWithECDSA.ts +17 -20
- package/_cjs/clients/bundler.js.map +0 -1
- package/_esm/clients/bundler.js.map +0 -1
- package/_types/clients/bundler.d.ts.map +0 -1
- package/tsconfig.build.tsbuildinfo +0 -1
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
Account,
|
|
3
|
+
Chain,
|
|
4
|
+
Client,
|
|
5
|
+
PublicClientConfig,
|
|
6
|
+
Transport
|
|
7
|
+
} from "viem"
|
|
2
8
|
import { createClient } from "viem"
|
|
3
9
|
import type { BundlerRpcSchema } from "../types/bundler.js"
|
|
4
10
|
import { type BundlerActions, bundlerActions } from "./decorators/bundler.js"
|
|
5
11
|
|
|
6
|
-
export type BundlerClient<
|
|
12
|
+
export type BundlerClient<
|
|
13
|
+
TChain extends Chain | undefined = Chain | undefined
|
|
14
|
+
> = Client<
|
|
7
15
|
Transport,
|
|
8
16
|
TChain,
|
|
9
17
|
Account | undefined,
|
|
@@ -29,7 +37,10 @@ export type BundlerClient<TChain extends Chain | undefined = Chain | undefined>
|
|
|
29
37
|
* transport: http(BUNDLER_URL),
|
|
30
38
|
* })
|
|
31
39
|
*/
|
|
32
|
-
export const createBundlerClient = <
|
|
40
|
+
export const createBundlerClient = <
|
|
41
|
+
transport extends Transport,
|
|
42
|
+
chain extends Chain | undefined = undefined
|
|
43
|
+
>(
|
|
33
44
|
parameters: PublicClientConfig<transport, chain>
|
|
34
45
|
): BundlerClient => {
|
|
35
46
|
const { key = "public", name = "Bundler Client" } = parameters
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Chain,
|
|
3
|
+
Client,
|
|
4
|
+
ClientConfig,
|
|
5
|
+
ParseAccount,
|
|
6
|
+
Transport,
|
|
7
|
+
WalletClientConfig
|
|
8
|
+
} from "viem"
|
|
9
|
+
import { createClient } from "viem"
|
|
10
|
+
import { type SmartAccount } from "../accounts/types.js"
|
|
11
|
+
import { type SponsorUserOperationMiddleware } from "../actions/smartAccount/prepareUserOperationRequest.js"
|
|
12
|
+
import { type BundlerRpcSchema } from "../types/bundler.js"
|
|
13
|
+
import type { Prettify } from "../types/index.js"
|
|
14
|
+
import {
|
|
15
|
+
type SmartAccountActions,
|
|
16
|
+
smartAccountActions
|
|
17
|
+
} from "./decorators/smartAccount.js"
|
|
18
|
+
|
|
19
|
+
export type SmartAccountClient<
|
|
20
|
+
transport extends Transport = Transport,
|
|
21
|
+
chain extends Chain | undefined = Chain | undefined,
|
|
22
|
+
account extends SmartAccount | undefined = SmartAccount | undefined
|
|
23
|
+
> = Prettify<
|
|
24
|
+
Client<
|
|
25
|
+
transport,
|
|
26
|
+
chain,
|
|
27
|
+
account,
|
|
28
|
+
BundlerRpcSchema,
|
|
29
|
+
SmartAccountActions<chain, account>
|
|
30
|
+
>
|
|
31
|
+
>
|
|
32
|
+
|
|
33
|
+
export type SmartAccountClientConfig<
|
|
34
|
+
transport extends Transport = Transport,
|
|
35
|
+
chain extends Chain | undefined = Chain | undefined,
|
|
36
|
+
TAccount extends SmartAccount | undefined = SmartAccount | undefined
|
|
37
|
+
> = Prettify<
|
|
38
|
+
Pick<
|
|
39
|
+
ClientConfig<transport, chain, TAccount>,
|
|
40
|
+
| "account"
|
|
41
|
+
| "cacheTime"
|
|
42
|
+
| "chain"
|
|
43
|
+
| "key"
|
|
44
|
+
| "name"
|
|
45
|
+
| "pollingInterval"
|
|
46
|
+
| "transport"
|
|
47
|
+
>
|
|
48
|
+
>
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Creates a EIP-4337 compliant Bundler Client with a given [Transport](https://viem.sh/docs/clients/intro.html) configured for a [Chain](https://viem.sh/docs/clients/chains.html).
|
|
52
|
+
*
|
|
53
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/clients/smartAccountClient
|
|
54
|
+
*
|
|
55
|
+
* A Bundler Client is an interface to "erc 4337" [JSON-RPC API](https://eips.ethereum.org/EIPS/eip-4337#rpc-methods-eth-namespace) methods such as sending user operation, estimating gas for a user operation, get user operation receipt, etc through Bundler Actions.
|
|
56
|
+
*
|
|
57
|
+
* @param config - {@link WalletClientConfig}
|
|
58
|
+
* @returns A Bundler Client. {@link SmartAccountClient}
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* import { createPublicClient, http } from 'viem'
|
|
62
|
+
* import { mainnet } from 'viem/chains'
|
|
63
|
+
*
|
|
64
|
+
* const smartAccountClient = createSmartAccountClient({
|
|
65
|
+
* chain: mainnet,
|
|
66
|
+
* transport: http(BUNDLER_URL),
|
|
67
|
+
* })
|
|
68
|
+
*/
|
|
69
|
+
export const createSmartAccountClient = <
|
|
70
|
+
TTransport extends Transport,
|
|
71
|
+
TChain extends Chain | undefined = undefined,
|
|
72
|
+
TSmartAccount extends SmartAccount | undefined = undefined
|
|
73
|
+
>(
|
|
74
|
+
parameters: SmartAccountClientConfig<TTransport, TChain, TSmartAccount> &
|
|
75
|
+
SponsorUserOperationMiddleware
|
|
76
|
+
): SmartAccountClient<TTransport, TChain, ParseAccount<TSmartAccount>> => {
|
|
77
|
+
const {
|
|
78
|
+
key = "Account",
|
|
79
|
+
name = "Smart Account Client",
|
|
80
|
+
transport
|
|
81
|
+
} = parameters
|
|
82
|
+
const client = createClient({
|
|
83
|
+
...parameters,
|
|
84
|
+
key,
|
|
85
|
+
name,
|
|
86
|
+
transport: (opts) => transport({ ...opts, retryCount: 0 }),
|
|
87
|
+
type: "smartAccountClient"
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
return client.extend(
|
|
91
|
+
smartAccountActions({
|
|
92
|
+
sponsorUserOperation: parameters.sponsorUserOperation
|
|
93
|
+
})
|
|
94
|
+
)
|
|
95
|
+
}
|
|
@@ -16,13 +16,16 @@ import {
|
|
|
16
16
|
type GetUserOperationReceiptReturnType,
|
|
17
17
|
getUserOperationReceipt
|
|
18
18
|
} from "../../actions/bundler/getUserOperationReceipt.js"
|
|
19
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
type SendUserOperationParameters,
|
|
21
|
+
sendUserOperation
|
|
22
|
+
} from "../../actions/bundler/sendUserOperation.js"
|
|
20
23
|
import { supportedEntryPoints } from "../../actions/bundler/supportedEntryPoints.js"
|
|
21
24
|
import {
|
|
22
25
|
type WaitForUserOperationReceiptParameters,
|
|
23
26
|
waitForUserOperationReceipt
|
|
24
27
|
} from "../../actions/bundler/waitForUserOperationReceipt.js"
|
|
25
|
-
import type { BundlerClient } from "../
|
|
28
|
+
import type { BundlerClient } from "../createBundlerClient.js"
|
|
26
29
|
|
|
27
30
|
export type BundlerActions = {
|
|
28
31
|
/**
|
|
@@ -40,7 +43,7 @@ export type BundlerActions = {
|
|
|
40
43
|
*
|
|
41
44
|
* const bundlerClient = createClient({
|
|
42
45
|
* chain: goerli,
|
|
43
|
-
* transport: http("https://api.pimlico.io/
|
|
46
|
+
* transport: http("https://api.pimlico.io/v2/goerli/rpc?apikey=YOUR_API_KEY_HERE")
|
|
44
47
|
* }).extend(bundlerActions)
|
|
45
48
|
*
|
|
46
49
|
* const userOpHash = await bundlerClient.sendUserOperation({
|
|
@@ -76,7 +79,9 @@ export type BundlerActions = {
|
|
|
76
79
|
*
|
|
77
80
|
* // Return {preVerificationGas: 43492n, verificationGasLimit: 59436n, callGasLimit: 9000n}
|
|
78
81
|
*/
|
|
79
|
-
estimateUserOperationGas: (
|
|
82
|
+
estimateUserOperationGas: (
|
|
83
|
+
args: EstimateUserOperationGasParameters
|
|
84
|
+
) => Promise<EstimateUserOperationGasReturnType>
|
|
80
85
|
/**
|
|
81
86
|
*
|
|
82
87
|
* Returns the supported entrypoints by the bundler service
|
|
@@ -141,7 +146,9 @@ export type BundlerActions = {
|
|
|
141
146
|
* await bundlerClient.getUserOperationByHash(userOpHash)
|
|
142
147
|
*
|
|
143
148
|
*/
|
|
144
|
-
getUserOperationByHash: (
|
|
149
|
+
getUserOperationByHash: (
|
|
150
|
+
args: GetUserOperationByHashParameters
|
|
151
|
+
) => Promise<GetUserOperationByHashReturnType>
|
|
145
152
|
/**
|
|
146
153
|
*
|
|
147
154
|
* Returns the user operation receipt from userOpHash
|
|
@@ -194,18 +201,21 @@ export type BundlerActions = {
|
|
|
194
201
|
}
|
|
195
202
|
|
|
196
203
|
const bundlerActions = (client: Client): BundlerActions => ({
|
|
197
|
-
sendUserOperation: async (
|
|
198
|
-
|
|
204
|
+
sendUserOperation: async (
|
|
205
|
+
args: SendUserOperationParameters
|
|
206
|
+
): Promise<Hash> => sendUserOperation(client as BundlerClient, args),
|
|
199
207
|
estimateUserOperationGas: (args: EstimateUserOperationGasParameters) =>
|
|
200
208
|
estimateUserOperationGas(client as BundlerClient, args),
|
|
201
|
-
supportedEntryPoints: (): Promise<Address[]> =>
|
|
209
|
+
supportedEntryPoints: (): Promise<Address[]> =>
|
|
210
|
+
supportedEntryPoints(client as BundlerClient),
|
|
202
211
|
chainId: () => chainId(client as BundlerClient),
|
|
203
212
|
getUserOperationByHash: (args: GetUserOperationByHashParameters) =>
|
|
204
213
|
getUserOperationByHash(client as BundlerClient, args),
|
|
205
214
|
getUserOperationReceipt: (args: GetUserOperationReceiptParameters) =>
|
|
206
215
|
getUserOperationReceipt(client as BundlerClient, args),
|
|
207
|
-
waitForUserOperationReceipt: (
|
|
208
|
-
|
|
216
|
+
waitForUserOperationReceipt: (
|
|
217
|
+
args: WaitForUserOperationReceiptParameters
|
|
218
|
+
) => waitForUserOperationReceipt(client as BundlerClient, args)
|
|
209
219
|
})
|
|
210
220
|
|
|
211
221
|
export { bundlerActions }
|
|
@@ -13,7 +13,10 @@ import {
|
|
|
13
13
|
type SponsorUserOperationReturnType,
|
|
14
14
|
sponsorUserOperation
|
|
15
15
|
} from "../../actions/pimlico/sponsorUserOperation.js"
|
|
16
|
-
import type {
|
|
16
|
+
import type {
|
|
17
|
+
PimlicoBundlerClient,
|
|
18
|
+
PimlicoPaymasterClient
|
|
19
|
+
} from "../pimlico.js"
|
|
17
20
|
|
|
18
21
|
export type PimlicoBundlerActions = {
|
|
19
22
|
/**
|
|
@@ -30,7 +33,7 @@ export type PimlicoBundlerActions = {
|
|
|
30
33
|
*
|
|
31
34
|
* const bundlerClient = createClient({
|
|
32
35
|
* chain: goerli,
|
|
33
|
-
* transport: http("https://api.pimlico.io/
|
|
36
|
+
* transport: http("https://api.pimlico.io/v2/goerli/rpc?apikey=YOUR_API_KEY_HERE")
|
|
34
37
|
* }).extend(pimlicoBundlerActions)
|
|
35
38
|
*
|
|
36
39
|
* await bundlerClient.getUserOperationGasPrice()
|
|
@@ -50,16 +53,21 @@ export type PimlicoBundlerActions = {
|
|
|
50
53
|
*
|
|
51
54
|
* const bundlerClient = createClient({
|
|
52
55
|
* chain: goerli,
|
|
53
|
-
* transport: http("https://api.pimlico.io/
|
|
56
|
+
* transport: http("https://api.pimlico.io/v2/goerli/rpc?apikey=YOUR_API_KEY_HERE")
|
|
54
57
|
* }).extend(pimlicoBundlerActions)
|
|
55
58
|
*
|
|
56
59
|
* await bundlerClient.getUserOperationStatus({ hash: userOpHash })
|
|
57
60
|
*/
|
|
58
|
-
getUserOperationStatus: (
|
|
61
|
+
getUserOperationStatus: (
|
|
62
|
+
args: GetUserOperationStatusParameters
|
|
63
|
+
) => Promise<GetUserOperationStatusReturnType>
|
|
59
64
|
}
|
|
60
65
|
|
|
61
|
-
export const pimlicoBundlerActions = (
|
|
62
|
-
|
|
66
|
+
export const pimlicoBundlerActions = (
|
|
67
|
+
client: Client
|
|
68
|
+
): PimlicoBundlerActions => ({
|
|
69
|
+
getUserOperationGasPrice: async () =>
|
|
70
|
+
getUserOperationGasPrice(client as PimlicoBundlerClient),
|
|
63
71
|
getUserOperationStatus: async (args: GetUserOperationStatusParameters) =>
|
|
64
72
|
getUserOperationStatus(client as PimlicoBundlerClient, args)
|
|
65
73
|
})
|
|
@@ -88,16 +96,20 @@ export type PimlicoPaymasterClientActions = {
|
|
|
88
96
|
* }})
|
|
89
97
|
*
|
|
90
98
|
*/
|
|
91
|
-
sponsorUserOperation: (
|
|
99
|
+
sponsorUserOperation: (
|
|
100
|
+
args: SponsorUserOperationParameters
|
|
101
|
+
) => Promise<SponsorUserOperationReturnType>
|
|
92
102
|
}
|
|
93
103
|
|
|
94
|
-
export const pimlicoPaymasterActions = (
|
|
104
|
+
export const pimlicoPaymasterActions = (
|
|
105
|
+
client: Client
|
|
106
|
+
): PimlicoPaymasterClientActions => ({
|
|
95
107
|
sponsorUserOperation: async (args: SponsorUserOperationParameters) =>
|
|
96
108
|
sponsorUserOperation(client as PimlicoPaymasterClient, args)
|
|
97
109
|
})
|
|
98
110
|
|
|
99
111
|
/**
|
|
100
|
-
* TODO: Add support for pimlicoActions after we support all the actions of
|
|
112
|
+
* TODO: Add support for pimlicoActions after we support all the actions of v2 of the Pimlico API.
|
|
101
113
|
*/
|
|
102
114
|
// export const pimlicoActions = (client: Client) => {
|
|
103
115
|
// return {
|