permissionless 0.0.5 → 0.0.7

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.
Files changed (211) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/_cjs/actions/bundler/chainId.js +11 -0
  3. package/_cjs/actions/bundler/chainId.js.map +1 -0
  4. package/_cjs/actions/bundler/estimateUserOperationGas.js +18 -0
  5. package/_cjs/actions/bundler/estimateUserOperationGas.js.map +1 -0
  6. package/_cjs/actions/bundler/getUserOperationByHash.js +30 -0
  7. package/_cjs/actions/bundler/getUserOperationByHash.js.map +1 -0
  8. package/_cjs/actions/bundler/getUserOperationReceipt.js +48 -0
  9. package/_cjs/actions/bundler/getUserOperationReceipt.js.map +1 -0
  10. package/_cjs/actions/bundler/sendUserOperation.js +13 -0
  11. package/_cjs/actions/bundler/sendUserOperation.js.map +1 -0
  12. package/_cjs/actions/bundler/supportedEntryPoints.js +11 -0
  13. package/_cjs/actions/bundler/supportedEntryPoints.js.map +1 -0
  14. package/_cjs/actions/index.js +18 -11
  15. package/_cjs/actions/index.js.map +1 -1
  16. package/_cjs/actions/pimlico/getUserOperationGasPrice.js +25 -0
  17. package/_cjs/actions/pimlico/getUserOperationGasPrice.js.map +1 -0
  18. package/_cjs/actions/pimlico/getUserOperationStatus.js +11 -0
  19. package/_cjs/actions/pimlico/getUserOperationStatus.js.map +1 -0
  20. package/_cjs/actions/pimlico/sponsorUserOperation.js +18 -0
  21. package/_cjs/actions/pimlico/sponsorUserOperation.js.map +1 -0
  22. package/_cjs/actions/pimlico.js +10 -52
  23. package/_cjs/actions/pimlico.js.map +1 -1
  24. package/_cjs/actions/public/getAccountNonce.js +35 -0
  25. package/_cjs/actions/public/getAccountNonce.js.map +1 -0
  26. package/_cjs/actions/{public.js → public/getSenderAddress.js} +1 -1
  27. package/_cjs/actions/public/getSenderAddress.js.map +1 -0
  28. package/_cjs/actions/stackup/accounts.js +12 -0
  29. package/_cjs/actions/stackup/accounts.js.map +1 -0
  30. package/_cjs/actions/stackup/sponsorUserOperation.js +18 -0
  31. package/_cjs/actions/stackup/sponsorUserOperation.js.map +1 -0
  32. package/_cjs/actions/stackup.js +10 -0
  33. package/_cjs/actions/stackup.js.map +1 -0
  34. package/_cjs/clients/bundler.js +2 -2
  35. package/_cjs/clients/bundler.js.map +1 -1
  36. package/_cjs/clients/decorators/bundler.js +19 -0
  37. package/_cjs/clients/decorators/bundler.js.map +1 -0
  38. package/_cjs/clients/decorators/pimlico.js +16 -0
  39. package/_cjs/clients/decorators/pimlico.js.map +1 -0
  40. package/_cjs/clients/decorators/stackup.js +11 -0
  41. package/_cjs/clients/decorators/stackup.js.map +1 -0
  42. package/_cjs/clients/pimlico.js +4 -4
  43. package/_cjs/clients/pimlico.js.map +1 -1
  44. package/_cjs/clients/stackup.js +18 -0
  45. package/_cjs/clients/stackup.js.map +1 -0
  46. package/_cjs/index.js +24 -4
  47. package/_cjs/index.js.map +1 -1
  48. package/_cjs/types/stackup.js +3 -0
  49. package/_cjs/types/stackup.js.map +1 -0
  50. package/_cjs/utils/getUserOperationHash.js +38 -0
  51. package/_cjs/utils/getUserOperationHash.js.map +1 -0
  52. package/_cjs/utils/index.js +2 -34
  53. package/_cjs/utils/index.js.map +1 -1
  54. package/_esm/actions/bundler/chainId.js +29 -0
  55. package/_esm/actions/bundler/chainId.js.map +1 -0
  56. package/_esm/actions/bundler/estimateUserOperationGas.js +41 -0
  57. package/_esm/actions/bundler/estimateUserOperationGas.js.map +1 -0
  58. package/_esm/actions/bundler/getUserOperationByHash.js +48 -0
  59. package/_esm/actions/bundler/getUserOperationByHash.js.map +1 -0
  60. package/_esm/actions/bundler/getUserOperationReceipt.js +66 -0
  61. package/_esm/actions/bundler/getUserOperationReceipt.js.map +1 -0
  62. package/_esm/actions/bundler/sendUserOperation.js +36 -0
  63. package/_esm/actions/bundler/sendUserOperation.js.map +1 -0
  64. package/_esm/actions/bundler/supportedEntryPoints.js +29 -0
  65. package/_esm/actions/bundler/supportedEntryPoints.js.map +1 -0
  66. package/_esm/actions/index.js +9 -3
  67. package/_esm/actions/index.js.map +1 -1
  68. package/_esm/actions/pimlico/getUserOperationGasPrice.js +42 -0
  69. package/_esm/actions/pimlico/getUserOperationGasPrice.js.map +1 -0
  70. package/_esm/actions/pimlico/getUserOperationStatus.js +29 -0
  71. package/_esm/actions/pimlico/getUserOperationStatus.js.map +1 -0
  72. package/_esm/actions/pimlico/sponsorUserOperation.js +39 -0
  73. package/_esm/actions/pimlico/sponsorUserOperation.js.map +1 -0
  74. package/_esm/actions/pimlico.js +5 -123
  75. package/_esm/actions/pimlico.js.map +1 -1
  76. package/_esm/actions/public/getAccountNonce.js +57 -0
  77. package/_esm/actions/public/getAccountNonce.js.map +1 -0
  78. package/_esm/actions/{public.js → public/getSenderAddress.js} +3 -3
  79. package/_esm/actions/public/getSenderAddress.js.map +1 -0
  80. package/_esm/actions/stackup/accounts.js +30 -0
  81. package/_esm/actions/stackup/accounts.js.map +1 -0
  82. package/_esm/actions/stackup/sponsorUserOperation.js +40 -0
  83. package/_esm/actions/stackup/sponsorUserOperation.js.map +1 -0
  84. package/_esm/actions/stackup.js +5 -0
  85. package/_esm/actions/stackup.js.map +1 -0
  86. package/_esm/clients/bundler.js +1 -1
  87. package/_esm/clients/bundler.js.map +1 -1
  88. package/_esm/clients/decorators/bundler.js +16 -0
  89. package/_esm/clients/decorators/bundler.js.map +1 -0
  90. package/_esm/clients/decorators/pimlico.js +20 -0
  91. package/_esm/clients/decorators/pimlico.js.map +1 -0
  92. package/_esm/clients/decorators/stackup.js +8 -0
  93. package/_esm/clients/decorators/stackup.js.map +1 -0
  94. package/_esm/clients/pimlico.js +2 -2
  95. package/_esm/clients/pimlico.js.map +1 -1
  96. package/_esm/clients/stackup.js +33 -0
  97. package/_esm/clients/stackup.js.map +1 -0
  98. package/_esm/index.js +15 -4
  99. package/_esm/index.js.map +1 -1
  100. package/_esm/types/stackup.js +2 -0
  101. package/_esm/types/stackup.js.map +1 -0
  102. package/_esm/utils/getUserOperationHash.js +55 -0
  103. package/_esm/utils/getUserOperationHash.js.map +1 -0
  104. package/_esm/utils/index.js +1 -54
  105. package/_esm/utils/index.js.map +1 -1
  106. package/_types/actions/bundler/chainId.d.ts +25 -0
  107. package/_types/actions/bundler/chainId.d.ts.map +1 -0
  108. package/_types/actions/bundler/estimateUserOperationGas.d.ts +42 -0
  109. package/_types/actions/bundler/estimateUserOperationGas.d.ts.map +1 -0
  110. package/_types/actions/bundler/getUserOperationByHash.d.ts +37 -0
  111. package/_types/actions/bundler/getUserOperationByHash.d.ts.map +1 -0
  112. package/_types/actions/bundler/getUserOperationReceipt.d.ts +93 -0
  113. package/_types/actions/bundler/getUserOperationReceipt.d.ts.map +1 -0
  114. package/_types/actions/bundler/sendUserOperation.d.ts +36 -0
  115. package/_types/actions/bundler/sendUserOperation.d.ts.map +1 -0
  116. package/_types/actions/bundler/supportedEntryPoints.d.ts +26 -0
  117. package/_types/actions/bundler/supportedEntryPoints.d.ts.map +1 -0
  118. package/_types/actions/index.d.ts +17 -6
  119. package/_types/actions/index.d.ts.map +1 -1
  120. package/_types/actions/pimlico/getUserOperationGasPrice.d.ts +38 -0
  121. package/_types/actions/pimlico/getUserOperationGasPrice.d.ts.map +1 -0
  122. package/_types/actions/pimlico/getUserOperationStatus.d.ts +31 -0
  123. package/_types/actions/pimlico/getUserOperationStatus.d.ts.map +1 -0
  124. package/_types/actions/pimlico/sponsorUserOperation.d.ts +41 -0
  125. package/_types/actions/pimlico/sponsorUserOperation.d.ts.map +1 -0
  126. package/_types/actions/pimlico.d.ts +7 -177
  127. package/_types/actions/pimlico.d.ts.map +1 -1
  128. package/_types/actions/public/getAccountNonce.d.ts +34 -0
  129. package/_types/actions/public/getAccountNonce.d.ts.map +1 -0
  130. package/_types/actions/{public.d.ts → public/getSenderAddress.d.ts} +4 -5
  131. package/_types/actions/public/getSenderAddress.d.ts.map +1 -0
  132. package/_types/actions/stackup/accounts.d.ts +29 -0
  133. package/_types/actions/stackup/accounts.d.ts.map +1 -0
  134. package/_types/actions/stackup/sponsorUserOperation.d.ts +43 -0
  135. package/_types/actions/stackup/sponsorUserOperation.d.ts.map +1 -0
  136. package/_types/actions/stackup.d.ts +7 -0
  137. package/_types/actions/stackup.d.ts.map +1 -0
  138. package/_types/clients/bundler.d.ts +2 -2
  139. package/_types/clients/bundler.d.ts.map +1 -1
  140. package/_types/clients/decorators/bundler.d.ts +150 -0
  141. package/_types/clients/decorators/bundler.d.ts.map +1 -0
  142. package/_types/clients/decorators/pimlico.d.ts +78 -0
  143. package/_types/clients/decorators/pimlico.d.ts.map +1 -0
  144. package/_types/clients/decorators/stackup.d.ts +54 -0
  145. package/_types/clients/decorators/stackup.d.ts.map +1 -0
  146. package/_types/clients/pimlico.d.ts +3 -3
  147. package/_types/clients/pimlico.d.ts.map +1 -1
  148. package/_types/clients/stackup.d.ts +39 -0
  149. package/_types/clients/stackup.d.ts.map +1 -0
  150. package/_types/index.d.ts +26 -4
  151. package/_types/index.d.ts.map +1 -1
  152. package/_types/types/bundler.d.ts +1 -1
  153. package/_types/types/bundler.d.ts.map +1 -1
  154. package/_types/types/index.d.ts +1 -1
  155. package/_types/types/index.d.ts.map +1 -1
  156. package/_types/types/pimlico.d.ts +1 -1
  157. package/_types/types/pimlico.d.ts.map +1 -1
  158. package/_types/types/stackup.d.ts +35 -0
  159. package/_types/types/stackup.d.ts.map +1 -0
  160. package/_types/utils/getUserOperationHash.d.ts +30 -0
  161. package/_types/utils/getUserOperationHash.d.ts.map +1 -0
  162. package/_types/utils/index.d.ts +2 -30
  163. package/_types/utils/index.d.ts.map +1 -1
  164. package/actions/bundler/chainId.ts +32 -0
  165. package/actions/bundler/estimateUserOperationGas.ts +62 -0
  166. package/actions/bundler/getUserOperationByHash.ts +69 -0
  167. package/actions/bundler/getUserOperationReceipt.ts +109 -0
  168. package/actions/bundler/sendUserOperation.ts +45 -0
  169. package/actions/bundler/supportedEntryPoints.ts +31 -0
  170. package/actions/index.ts +23 -21
  171. package/actions/pimlico/getUserOperationGasPrice.ts +61 -0
  172. package/actions/pimlico/getUserOperationStatus.ts +41 -0
  173. package/actions/pimlico/sponsorUserOperation.ts +62 -0
  174. package/actions/pimlico.ts +34 -251
  175. package/actions/public/getAccountNonce.ts +63 -0
  176. package/actions/{public.ts → public/getSenderAddress.ts} +9 -9
  177. package/actions/stackup/accounts.ts +40 -0
  178. package/actions/stackup/sponsorUserOperation.ts +64 -0
  179. package/actions/stackup.ts +17 -0
  180. package/clients/bundler.ts +2 -3
  181. package/clients/decorators/bundler.ts +178 -0
  182. package/clients/decorators/pimlico.ts +107 -0
  183. package/clients/decorators/stackup.ts +65 -0
  184. package/clients/pimlico.ts +3 -4
  185. package/clients/stackup.ts +44 -0
  186. package/index.ts +62 -4
  187. package/package.json +11 -1
  188. package/tsconfig.build.tsbuildinfo +1 -1
  189. package/types/bundler.ts +1 -1
  190. package/types/index.ts +1 -1
  191. package/types/pimlico.ts +1 -1
  192. package/types/stackup.ts +36 -0
  193. package/utils/getUserOperationHash.ts +68 -0
  194. package/utils/index.ts +2 -69
  195. package/_cjs/actions/bundler.js +0 -118
  196. package/_cjs/actions/bundler.js.map +0 -1
  197. package/_cjs/actions/public.js.map +0 -1
  198. package/_cjs/clients/index.js +0 -6
  199. package/_cjs/clients/index.js.map +0 -1
  200. package/_esm/actions/bundler.js +0 -251
  201. package/_esm/actions/bundler.js.map +0 -1
  202. package/_esm/actions/public.js.map +0 -1
  203. package/_esm/clients/index.js +0 -3
  204. package/_esm/clients/index.js.map +0 -1
  205. package/_types/actions/bundler.d.ts +0 -393
  206. package/_types/actions/bundler.d.ts.map +0 -1
  207. package/_types/actions/public.d.ts.map +0 -1
  208. package/_types/clients/index.d.ts +0 -3
  209. package/_types/clients/index.d.ts.map +0 -1
  210. package/actions/bundler.ts +0 -498
  211. package/clients/index.ts +0 -3
@@ -0,0 +1,62 @@
1
+ import type { Address, Hex } from "viem"
2
+ import type { PartialBy } from "viem/types/utils"
3
+ import type { PimlicoPaymasterClient } from "../../clients/pimlico.js"
4
+ import type { UserOperation, UserOperationWithBigIntAsHex } from "../../types/userOperation.js"
5
+ import { deepHexlify } from "../utils.js"
6
+
7
+ export type SponsorUserOperationParameters = {
8
+ userOperation: PartialBy<
9
+ UserOperation,
10
+ "callGasLimit" | "preVerificationGas" | "verificationGasLimit" | "paymasterAndData"
11
+ >
12
+ entryPoint: Address
13
+ }
14
+
15
+ export type SponsorUserOperationReturnType = {
16
+ paymasterAndData: Hex
17
+ preVerificationGas: bigint
18
+ verificationGasLimit: bigint
19
+ callGasLimit: bigint
20
+ }
21
+
22
+ /**
23
+ * Returns paymasterAndData & updated gas parameters required to sponsor a userOperation.
24
+ *
25
+ * - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-paymaster-actions/sponsorUserOperation
26
+ *
27
+ * @param client {@link PimlicoBundlerClient} that you created using viem's createClient whose transport url is pointing to the Pimlico's bundler.
28
+ * @param args {@link sponsorUserOperationParameters} UserOperation you want to sponsor & entryPoint.
29
+ * @returns paymasterAndData & updated gas parameters, see {@link SponsorUserOperationReturnType}
30
+ *
31
+ *
32
+ * @example
33
+ * import { createClient } from "viem"
34
+ * import { sponsorUserOperation } from "permissionless/actions/pimlico"
35
+ *
36
+ * const bundlerClient = createClient({
37
+ * chain: goerli,
38
+ * transport: http("https://api.pimlico.io/v2/goerli/rpc?apikey=YOUR_API_KEY_HERE")
39
+ * })
40
+ *
41
+ * await sponsorUserOperation(bundlerClient, {
42
+ * userOperation: userOperationWithDummySignature,
43
+ * entryPoint: entryPoint
44
+ * }})
45
+ *
46
+ */
47
+ export const sponsorUserOperation = async (
48
+ client: PimlicoPaymasterClient,
49
+ args: SponsorUserOperationParameters
50
+ ): Promise<SponsorUserOperationReturnType> => {
51
+ const response = await client.request({
52
+ method: "pm_sponsorUserOperation",
53
+ params: [deepHexlify(args.userOperation) as UserOperationWithBigIntAsHex, args.entryPoint]
54
+ })
55
+
56
+ return {
57
+ paymasterAndData: response.paymasterAndData,
58
+ preVerificationGas: BigInt(response.preVerificationGas),
59
+ verificationGasLimit: BigInt(response.verificationGasLimit),
60
+ callGasLimit: BigInt(response.callGasLimit)
61
+ }
62
+ }
@@ -1,252 +1,35 @@
1
- import type { Address, Client, Hash, Hex } from "viem"
2
- import type { PartialBy } from "viem/types/utils"
3
- import type { PimlicoBundlerClient, PimlicoPaymasterClient } from "../clients/pimlico"
4
- import type { PimlicoUserOperationStatus } from "../types/pimlico"
5
- import type { UserOperation, UserOperationWithBigIntAsHex } from "../types/userOperation"
6
- import { deepHexlify } from "./utils"
7
-
8
- export type SponsorUserOperationParameters = {
9
- userOperation: PartialBy<
10
- UserOperation,
11
- "callGasLimit" | "preVerificationGas" | "verificationGasLimit" | "paymasterAndData"
12
- >
13
- entryPoint: Address
14
- }
15
-
16
- export type SponsorUserOperationReturnType = {
17
- paymasterAndData: Hex
18
- preVerificationGas: bigint
19
- verificationGasLimit: bigint
20
- callGasLimit: bigint
21
- }
22
-
23
- export type GetUserOperationGasPriceReturnType = {
24
- slow: {
25
- maxFeePerGas: bigint
26
- maxPriorityFeePerGas: bigint
27
- }
28
- standard: {
29
- maxFeePerGas: bigint
30
- maxPriorityFeePerGas: bigint
31
- }
32
- fast: {
33
- maxFeePerGas: bigint
34
- maxPriorityFeePerGas: bigint
35
- }
36
- }
37
-
38
- export type GetUserOperationStatusParameters = {
39
- hash: Hash
40
- }
41
-
42
- export type GetUserOperationStatusReturnType = PimlicoUserOperationStatus
43
-
44
- /**
45
- * Returns the live gas prices that you can use to send a user operation.
46
- *
47
- * - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-bundler-actions/getUserOperationGasPrice
48
- *
49
- * @param client {@link PimlicoBundlerClient} that you created using viem's createClient whose transport url is pointing to the Pimlico's bundler.
50
- * @returns slow, standard & fast values for maxFeePerGas & maxPriorityFeePerGas
51
- *
52
- *
53
- * @example
54
- * import { createClient } from "viem"
55
- * import { getUserOperationGasPrice } from "permissionless/actions"
56
- *
57
- * const bundlerClient = createClient({
58
- * chain: goerli,
59
- * transport: http("https://api.pimlico.io/v1/goerli/rpc?apikey=YOUR_API_KEY_HERE")
60
- * })
61
- *
62
- * await getUserOperationGasPrice(bundlerClient)
63
- *
64
- */
65
- export const getUserOperationGasPrice = async (
66
- client: PimlicoBundlerClient
67
- ): Promise<GetUserOperationGasPriceReturnType> => {
68
- const gasPrices = await client.request({
69
- method: "pimlico_getUserOperationGasPrice",
70
- params: []
71
- })
72
-
73
- return {
74
- slow: {
75
- maxFeePerGas: BigInt(gasPrices.slow.maxFeePerGas),
76
- maxPriorityFeePerGas: BigInt(gasPrices.slow.maxPriorityFeePerGas)
77
- },
78
- standard: {
79
- maxFeePerGas: BigInt(gasPrices.standard.maxFeePerGas),
80
- maxPriorityFeePerGas: BigInt(gasPrices.standard.maxPriorityFeePerGas)
81
- },
82
- fast: {
83
- maxFeePerGas: BigInt(gasPrices.fast.maxFeePerGas),
84
- maxPriorityFeePerGas: BigInt(gasPrices.fast.maxPriorityFeePerGas)
85
- }
86
- }
1
+ import {
2
+ type GetUserOperationGasPriceReturnType,
3
+ getUserOperationGasPrice
4
+ } from "./pimlico/getUserOperationGasPrice.js"
5
+ import {
6
+ type GetUserOperationStatusParameters,
7
+ type GetUserOperationStatusReturnType,
8
+ getUserOperationStatus
9
+ } from "./pimlico/getUserOperationStatus.js"
10
+ import {
11
+ type SponsorUserOperationParameters,
12
+ type SponsorUserOperationReturnType,
13
+ sponsorUserOperation
14
+ } from "./pimlico/sponsorUserOperation.js"
15
+
16
+ import type { PimlicoBundlerActions, PimlicoPaymasterClientActions } from "../clients/decorators/pimlico.js"
17
+ import { pimlicoBundlerActions, pimlicoPaymasterActions } from "../clients/decorators/pimlico.js"
18
+
19
+ export type {
20
+ GetUserOperationGasPriceReturnType,
21
+ GetUserOperationStatusParameters,
22
+ GetUserOperationStatusReturnType,
23
+ SponsorUserOperationParameters,
24
+ SponsorUserOperationReturnType,
25
+ PimlicoBundlerActions,
26
+ PimlicoPaymasterClientActions
27
+ }
28
+
29
+ export {
30
+ getUserOperationGasPrice,
31
+ getUserOperationStatus,
32
+ sponsorUserOperation,
33
+ pimlicoBundlerActions,
34
+ pimlicoPaymasterActions
87
35
  }
88
-
89
- /**
90
- * Returns the status of the userOperation that is pending in the mempool.
91
- *
92
- * - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-bundler-actions/getUserOperationStatus
93
- *
94
- * @param client {@link PimlicoBundlerClient} that you created using viem's createClient whose transport url is pointing to the Pimlico's bundler.
95
- * @param hash {@link Hash} UserOpHash that you must have received from sendUserOperation.
96
- * @returns status & transaction hash if included {@link GetUserOperationStatusReturnType}
97
- *
98
- *
99
- * @example
100
- * import { createClient } from "viem"
101
- * import { getUserOperationStatus } from "permissionless/actions"
102
- *
103
- * const bundlerClient = createClient({
104
- * chain: goerli,
105
- * transport: http("https://api.pimlico.io/v1/goerli/rpc?apikey=YOUR_API_KEY_HERE")
106
- * })
107
- *
108
- * await getUserOperationStatus(bundlerClient, { hash: userOpHash })
109
- *
110
- */
111
- export const getUserOperationStatus = async (
112
- client: PimlicoBundlerClient,
113
- { hash }: GetUserOperationStatusParameters
114
- ): Promise<GetUserOperationStatusReturnType> => {
115
- return client.request({
116
- method: "pimlico_getUserOperationStatus",
117
- params: [hash]
118
- })
119
- }
120
-
121
- export type PimlicoBundlerActions = {
122
- /**
123
- * Returns the live gas prices that you can use to send a user operation.
124
- *
125
- * - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-bundler-actions/getUserOperationGasPrice
126
- *
127
- * @returns slow, standard & fast values for maxFeePerGas & maxPriorityFeePerGas {@link GetUserOperationGasPriceReturnType}
128
- *
129
- * @example
130
- *
131
- * import { createClient } from "viem"
132
- * import { pimlicoBundlerActions } from "permissionless/actions"
133
- *
134
- * const bundlerClient = createClient({
135
- * chain: goerli,
136
- * transport: http("https://api.pimlico.io/v1/goerli/rpc?apikey=YOUR_API_KEY_HERE")
137
- * }).extend(pimlicoBundlerActions)
138
- *
139
- * await bundlerClient.getUserOperationGasPrice()
140
- */
141
- getUserOperationGasPrice: () => Promise<GetUserOperationGasPriceReturnType>
142
- /**
143
- * Returns the status of the userOperation that is pending in the mempool.
144
- *
145
- * - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-bundler-actions/getUserOperationStatus
146
- *
147
- * @param hash {@link Hash} UserOpHash that you must have received from sendUserOperation.
148
- * @returns status & transaction hash if included {@link GetUserOperationStatusReturnType}
149
- *
150
- * @example
151
- * import { createClient } from "viem"
152
- * import { pimlicoBundlerActions } from "permissionless/actions"
153
- *
154
- * const bundlerClient = createClient({
155
- * chain: goerli,
156
- * transport: http("https://api.pimlico.io/v1/goerli/rpc?apikey=YOUR_API_KEY_HERE")
157
- * }).extend(pimlicoBundlerActions)
158
- *
159
- * await bundlerClient.getUserOperationStatus({ hash: userOpHash })
160
- */
161
- getUserOperationStatus: (args: GetUserOperationStatusParameters) => Promise<GetUserOperationStatusReturnType>
162
- }
163
-
164
- export const pimlicoBundlerActions = (client: Client): PimlicoBundlerActions => ({
165
- getUserOperationGasPrice: async () => getUserOperationGasPrice(client as PimlicoBundlerClient),
166
- getUserOperationStatus: async (args: GetUserOperationStatusParameters) =>
167
- getUserOperationStatus(client as PimlicoBundlerClient, args)
168
- })
169
-
170
- /**
171
- * Returns paymasterAndData & updated gas parameters required to sponsor a userOperation.
172
- *
173
- * - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-paymaster-actions/sponsorUserOperation
174
- *
175
- * @param client {@link PimlicoBundlerClient} that you created using viem's createClient whose transport url is pointing to the Pimlico's bundler.
176
- * @param args {@link sponsorUserOperationParameters} UserOperation you want to sponsor & entryPoint.
177
- * @returns paymasterAndData & updated gas parameters, see {@link SponsorUserOperationReturnType}
178
- *
179
- *
180
- * @example
181
- * import { createClient } from "viem"
182
- * import { sponsorUserOperation } from "permissionless/actions"
183
- *
184
- * const bundlerClient = createClient({
185
- * chain: goerli,
186
- * transport: http("https://api.pimlico.io/v2/goerli/rpc?apikey=YOUR_API_KEY_HERE")
187
- * })
188
- *
189
- * await sponsorUserOperation(bundlerClient, {
190
- * userOperation: userOperationWithDummySignature,
191
- * entryPoint: entryPoint
192
- * }})
193
- *
194
- */
195
- export const sponsorUserOperation = async (
196
- client: PimlicoPaymasterClient,
197
- args: SponsorUserOperationParameters
198
- ): Promise<SponsorUserOperationReturnType> => {
199
- const response = await client.request({
200
- method: "pm_sponsorUserOperation",
201
- params: [deepHexlify(args.userOperation) as UserOperationWithBigIntAsHex, args.entryPoint]
202
- })
203
-
204
- return {
205
- paymasterAndData: response.paymasterAndData,
206
- preVerificationGas: BigInt(response.preVerificationGas),
207
- verificationGasLimit: BigInt(response.verificationGasLimit),
208
- callGasLimit: BigInt(response.callGasLimit)
209
- }
210
- }
211
-
212
- export type PimlicoPaymasterClientActions = {
213
- /**
214
- * Returns paymasterAndData & updated gas parameters required to sponsor a userOperation.
215
- *
216
- * https://docs.pimlico.io/permissionless/reference/pimlico-paymaster-actions/sponsorUserOperation
217
- *
218
- * @param args {@link SponsorUserOperationParameters} UserOperation you want to sponsor & entryPoint.
219
- * @returns paymasterAndData & updated gas parameters, see {@link SponsorUserOperationReturnType}
220
- *
221
- * @example
222
- * import { createClient } from "viem"
223
- * import { sponsorUserOperation } from "permissionless/actions"
224
- *
225
- * const bundlerClient = createClient({
226
- * chain: goerli,
227
- * transport: http("https://api.pimlico.io/v2/goerli/rpc?apikey=YOUR_API_KEY_HERE")
228
- * }).extend(pimlicoPaymasterActions)
229
- *
230
- * await bundlerClient.sponsorUserOperation(bundlerClient, {
231
- * userOperation: userOperationWithDummySignature,
232
- * entryPoint: entryPoint
233
- * }})
234
- *
235
- */
236
- sponsorUserOperation: (args: SponsorUserOperationParameters) => Promise<SponsorUserOperationReturnType>
237
- }
238
-
239
- export const pimlicoPaymasterActions = (client: Client): PimlicoPaymasterClientActions => ({
240
- sponsorUserOperation: async (args: SponsorUserOperationParameters) =>
241
- sponsorUserOperation(client as PimlicoPaymasterClient, args)
242
- })
243
-
244
- /**
245
- * TODO: Add support for pimlicoActions after we support all the actions of v1 in v2 of the Pimlico API.
246
- */
247
- // export const pimlicoActions = (client: Client) => {
248
- // return {
249
- // ...pimlicoBundlerActions(client),
250
- // ...pimlicoPaymasterActions(client)
251
- // }
252
- // }
@@ -0,0 +1,63 @@
1
+ import type { Address, PublicClient } from "viem"
2
+
3
+ export type GetAccountNonceParams = { sender: Address; entryPoint: Address; key?: bigint }
4
+
5
+ /**
6
+ * Returns the nonce of the account with the entry point.
7
+ *
8
+ * - Docs: https://docs.pimlico.io/permissionless/reference/public-actions/getAccountNonce
9
+ *
10
+ * @param publicClient {@link PublicClient} that you created using viem's createPublicClient.
11
+ * @param args {@link GetAccountNonceParams} address, entryPoint & key
12
+ * @returns bigint nonce
13
+ *
14
+ * @example
15
+ * import { createPublicClient } from "viem"
16
+ * import { getAccountNonce } from "permissionless/actions"
17
+ *
18
+ * const publicClient = createPublicClient({
19
+ * chain: goerli,
20
+ * transport: http("https://goerli.infura.io/v3/your-infura-key")
21
+ * })
22
+ *
23
+ * const nonce = await getAccountNonce(publicClient, {
24
+ * address,
25
+ * entryPoint,
26
+ * key
27
+ * })
28
+ *
29
+ * // Return 0n
30
+ */
31
+ export const getAccountNonce = async (
32
+ publicClient: PublicClient,
33
+ { sender, entryPoint, key = BigInt(0) }: GetAccountNonceParams
34
+ ): Promise<bigint> => {
35
+ return await publicClient.readContract({
36
+ address: entryPoint,
37
+ abi: [
38
+ {
39
+ inputs: [
40
+ {
41
+ name: "sender",
42
+ type: "address"
43
+ },
44
+ {
45
+ name: "key",
46
+ type: "uint192"
47
+ }
48
+ ],
49
+ name: "getNonce",
50
+ outputs: [
51
+ {
52
+ name: "nonce",
53
+ type: "uint256"
54
+ }
55
+ ],
56
+ stateMutability: "view",
57
+ type: "function"
58
+ }
59
+ ],
60
+ functionName: "getNonce",
61
+ args: [sender, key]
62
+ })
63
+ }
@@ -1,11 +1,11 @@
1
- import type {
2
- Address,
3
- ContractFunctionExecutionErrorType,
4
- ContractFunctionRevertedErrorType,
5
- Hex,
6
- PublicClient
1
+ import {
2
+ type Address,
3
+ BaseError,
4
+ type ContractFunctionExecutionErrorType,
5
+ type ContractFunctionRevertedErrorType,
6
+ type Hex,
7
+ type PublicClient
7
8
  } from "viem"
8
- import { BaseError } from "viem"
9
9
 
10
10
  export type GetSenderAddressParams = { initCode: Hex; entryPoint: Address }
11
11
 
@@ -31,8 +31,8 @@ export class InvalidEntryPointError extends BaseError {
31
31
  *
32
32
  *
33
33
  * @param publicClient {@link PublicClient} that you created using viem's createPublicClient.
34
- * @param args {@link GetSenderAddressParams}
35
- * @returns Address
34
+ * @param args {@link GetSenderAddressParams} initCode & entryPoint
35
+ * @returns Sender's Address
36
36
  *
37
37
  * @example
38
38
  * import { createPublicClient } from "viem"
@@ -0,0 +1,40 @@
1
+ import type { Address } from "viem"
2
+ import type { StackupPaymasterClient } from "../../clients/stackup.js"
3
+
4
+ export type AccountsParameters = {
5
+ entryPoint: Address
6
+ }
7
+
8
+ /**
9
+ * Returns all the Paymaster addresses associated with an EntryPoint that’s owned by this service.
10
+ *
11
+ * https://docs.stackup.sh/docs/paymaster-api-rpc-methods#pm_accounts
12
+ *
13
+ * @param args {@link AccountsParameters} entryPoint for which you want to get list of supported paymasters.
14
+ * @returns paymaster addresses
15
+ *
16
+ * @example
17
+ * import { createClient } from "viem"
18
+ * import { accounts } from "permissionless/actions/stackup"
19
+ *
20
+ * const bundlerClient = createClient({
21
+ * chain: goerli,
22
+ * transport: http("https://api.stackup.sh/v1/paymaster/YOUR_API_KEY_HERE")
23
+ * })
24
+ *
25
+ * await accounts(bundlerClient, {
26
+ * entryPoint: entryPoint
27
+ * }})
28
+ *
29
+ */
30
+ export const accounts = async (
31
+ client: StackupPaymasterClient,
32
+ { entryPoint }: AccountsParameters
33
+ ): Promise<Address[]> => {
34
+ const response = await client.request({
35
+ method: "pm_accounts",
36
+ params: [entryPoint]
37
+ })
38
+
39
+ return response
40
+ }
@@ -0,0 +1,64 @@
1
+ import type { Address, Hex } from "viem"
2
+ import type { PartialBy } from "viem/types/utils"
3
+ import { type StackupPaymasterClient } from "../../clients/stackup.js"
4
+ import type { StackupPaymasterContext } from "../../types/stackup.js"
5
+ import type { UserOperation, UserOperationWithBigIntAsHex } from "../../types/userOperation.js"
6
+ import { deepHexlify } from "../utils.js"
7
+
8
+ export type SponsorUserOperationParameters = {
9
+ userOperation: PartialBy<
10
+ UserOperation,
11
+ "callGasLimit" | "preVerificationGas" | "verificationGasLimit" | "paymasterAndData"
12
+ >
13
+ entryPoint: Address
14
+ context: StackupPaymasterContext
15
+ }
16
+
17
+ export type SponsorUserOperationReturnType = {
18
+ paymasterAndData: Hex
19
+ preVerificationGas: bigint
20
+ verificationGasLimit: bigint
21
+ callGasLimit: bigint
22
+ }
23
+
24
+ /**
25
+ * Returns paymasterAndData & updated gas parameters required to sponsor a userOperation.
26
+ *
27
+ * - Docs: https://docs.pimlico.io/permissionless/reference/stackup-paymaster-actions/sponsorUserOperation
28
+ *
29
+ * @param client {@link PimlicoBundlerClient} that you created using viem's createClient whose transport url is pointing to the Pimlico's bundler.
30
+ * @param args {@link sponsorUserOperationParameters} UserOperation you want to sponsor & entryPoint.
31
+ * @returns paymasterAndData & updated gas parameters, see {@link SponsorUserOperationReturnType}
32
+ *
33
+ *
34
+ * @example
35
+ * import { createClient } from "viem"
36
+ * import { sponsorUserOperation } from "permissionless/actions/stackup"
37
+ *
38
+ * const bundlerClient = createClient({
39
+ * chain: goerli,
40
+ * transport: http("https://api.stackup.sh/v1/paymaster/YOUR_API_KEY_HERE")
41
+ * })
42
+ *
43
+ * await sponsorUserOperation(bundlerClient, {
44
+ * userOperation: userOperationWithDummySignature,
45
+ * entryPoint: entryPoint
46
+ * }})
47
+ *
48
+ */
49
+ export const sponsorUserOperation = async (
50
+ client: StackupPaymasterClient,
51
+ args: SponsorUserOperationParameters
52
+ ): Promise<SponsorUserOperationReturnType> => {
53
+ const response = await client.request({
54
+ method: "pm_sponsorUserOperation",
55
+ params: [deepHexlify(args.userOperation) as UserOperationWithBigIntAsHex, args.entryPoint, args.context]
56
+ })
57
+
58
+ return {
59
+ paymasterAndData: response.paymasterAndData,
60
+ preVerificationGas: BigInt(response.preVerificationGas),
61
+ verificationGasLimit: BigInt(response.verificationGasLimit),
62
+ callGasLimit: BigInt(response.callGasLimit)
63
+ }
64
+ }
@@ -0,0 +1,17 @@
1
+ import type { StackupPaymasterClientActions } from "../clients/decorators/stackup.js"
2
+ import { stackupPaymasterActions } from "../clients/decorators/stackup.js"
3
+ import { type AccountsParameters, accounts } from "./stackup/accounts.js"
4
+ import {
5
+ type SponsorUserOperationParameters,
6
+ type SponsorUserOperationReturnType,
7
+ sponsorUserOperation
8
+ } from "./stackup/sponsorUserOperation.js"
9
+
10
+ export type {
11
+ SponsorUserOperationParameters,
12
+ SponsorUserOperationReturnType,
13
+ AccountsParameters,
14
+ StackupPaymasterClientActions
15
+ }
16
+
17
+ export { sponsorUserOperation, accounts, stackupPaymasterActions }
@@ -1,8 +1,7 @@
1
1
  import type { Account, Chain, Client, PublicClientConfig, Transport } from "viem"
2
2
  import { createClient } from "viem"
3
- import { bundlerActions } from "../actions"
4
- import type { BundlerActions } from "../actions/bundler"
5
- import type { BundlerRpcSchema } from "../types/bundler"
3
+ import type { BundlerRpcSchema } from "../types/bundler.js"
4
+ import { type BundlerActions, bundlerActions } from "./decorators/bundler.js"
6
5
 
7
6
  export type BundlerClient = Client<Transport, Chain | undefined, Account | undefined, BundlerRpcSchema, BundlerActions>
8
7
  /**