permissionless 0.0.13 → 0.0.15

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 (77) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/_cjs/accounts/index.js +3 -1
  3. package/_cjs/accounts/index.js.map +1 -1
  4. package/_cjs/accounts/kernel/abi/KernelAccountAbi.js +84 -0
  5. package/_cjs/accounts/kernel/abi/KernelAccountAbi.js.map +1 -0
  6. package/_cjs/accounts/kernel/signerToEcdsaKernelSmartAccount.js +211 -0
  7. package/_cjs/accounts/kernel/signerToEcdsaKernelSmartAccount.js.map +1 -0
  8. package/_cjs/accounts/signerToSafeSmartAccount.js +2 -2
  9. package/_cjs/actions/pimlico/sponsorUserOperation.js +12 -4
  10. package/_cjs/actions/pimlico/sponsorUserOperation.js.map +1 -1
  11. package/_cjs/actions/pimlico/validateSponsorshipPolicies.js +16 -0
  12. package/_cjs/actions/pimlico/validateSponsorshipPolicies.js.map +1 -0
  13. package/_cjs/actions/pimlico.js +3 -1
  14. package/_cjs/actions/pimlico.js.map +1 -1
  15. package/_cjs/clients/createSmartAccountClient.js.map +1 -1
  16. package/_cjs/clients/decorators/pimlico.js +3 -1
  17. package/_cjs/clients/decorators/pimlico.js.map +1 -1
  18. package/_cjs/utils/getRequiredPrefund.js +12 -0
  19. package/_cjs/utils/getRequiredPrefund.js.map +1 -0
  20. package/_cjs/utils/index.js +3 -1
  21. package/_cjs/utils/index.js.map +1 -1
  22. package/_esm/accounts/index.js +2 -1
  23. package/_esm/accounts/index.js.map +1 -1
  24. package/_esm/accounts/kernel/abi/KernelAccountAbi.js +87 -0
  25. package/_esm/accounts/kernel/abi/KernelAccountAbi.js.map +1 -0
  26. package/_esm/accounts/kernel/signerToEcdsaKernelSmartAccount.js +262 -0
  27. package/_esm/accounts/kernel/signerToEcdsaKernelSmartAccount.js.map +1 -0
  28. package/_esm/accounts/signerToSafeSmartAccount.js +2 -2
  29. package/_esm/actions/pimlico/sponsorUserOperation.js +13 -5
  30. package/_esm/actions/pimlico/sponsorUserOperation.js.map +1 -1
  31. package/_esm/actions/pimlico/validateSponsorshipPolicies.js +47 -0
  32. package/_esm/actions/pimlico/validateSponsorshipPolicies.js.map +1 -0
  33. package/_esm/actions/pimlico.js +2 -1
  34. package/_esm/actions/pimlico.js.map +1 -1
  35. package/_esm/clients/createSmartAccountClient.js +1 -1
  36. package/_esm/clients/createSmartAccountClient.js.map +1 -1
  37. package/_esm/clients/decorators/pimlico.js +38 -1
  38. package/_esm/clients/decorators/pimlico.js.map +1 -1
  39. package/_esm/utils/getRequiredPrefund.js +22 -0
  40. package/_esm/utils/getRequiredPrefund.js.map +1 -0
  41. package/_esm/utils/index.js +2 -1
  42. package/_esm/utils/index.js.map +1 -1
  43. package/_types/accounts/index.d.ts +2 -1
  44. package/_types/accounts/index.d.ts.map +1 -1
  45. package/_types/accounts/kernel/abi/KernelAccountAbi.d.ts +68 -0
  46. package/_types/accounts/kernel/abi/KernelAccountAbi.d.ts.map +1 -0
  47. package/_types/accounts/kernel/signerToEcdsaKernelSmartAccount.d.ts +25 -0
  48. package/_types/accounts/kernel/signerToEcdsaKernelSmartAccount.d.ts.map +1 -0
  49. package/_types/actions/pimlico/sponsorUserOperation.d.ts +4 -3
  50. package/_types/actions/pimlico/sponsorUserOperation.d.ts.map +1 -1
  51. package/_types/actions/pimlico/validateSponsorshipPolicies.d.ts +54 -0
  52. package/_types/actions/pimlico/validateSponsorshipPolicies.d.ts.map +1 -0
  53. package/_types/actions/pimlico.d.ts +4 -3
  54. package/_types/actions/pimlico.d.ts.map +1 -1
  55. package/_types/clients/createSmartAccountClient.d.ts +6 -1
  56. package/_types/clients/createSmartAccountClient.d.ts.map +1 -1
  57. package/_types/clients/decorators/pimlico.d.ts +40 -3
  58. package/_types/clients/decorators/pimlico.d.ts.map +1 -1
  59. package/_types/types/pimlico.d.ts +21 -1
  60. package/_types/types/pimlico.d.ts.map +1 -1
  61. package/_types/utils/getRequiredPrefund.d.ts +20 -0
  62. package/_types/utils/getRequiredPrefund.d.ts.map +1 -0
  63. package/_types/utils/index.d.ts +2 -1
  64. package/_types/utils/index.d.ts.map +1 -1
  65. package/accounts/index.ts +8 -1
  66. package/accounts/kernel/abi/KernelAccountAbi.ts +87 -0
  67. package/accounts/kernel/signerToEcdsaKernelSmartAccount.ts +363 -0
  68. package/accounts/signerToSafeSmartAccount.ts +2 -2
  69. package/actions/pimlico/sponsorUserOperation.ts +20 -7
  70. package/actions/pimlico/validateSponsorshipPolicies.ts +76 -0
  71. package/actions/pimlico.ts +13 -4
  72. package/clients/createSmartAccountClient.ts +6 -1
  73. package/clients/decorators/pimlico.ts +52 -5
  74. package/package.json +1 -1
  75. package/types/pimlico.ts +21 -1
  76. package/utils/getRequiredPrefund.ts +31 -0
  77. package/utils/index.ts +6 -0
package/types/pimlico.ts CHANGED
@@ -53,7 +53,10 @@ export type PimlicoPaymasterRpcSchema = [
53
53
  | "verificationGasLimit"
54
54
  | "paymasterAndData"
55
55
  >,
56
- entryPoint: Address
56
+ entryPoint: Address,
57
+ metadata?: {
58
+ sponsorshipPolicyId?: string
59
+ }
57
60
  ]
58
61
  ReturnType: {
59
62
  paymasterAndData: Hex
@@ -61,5 +64,22 @@ export type PimlicoPaymasterRpcSchema = [
61
64
  verificationGasLimit: Hex
62
65
  callGasLimit: Hex
63
66
  }
67
+ },
68
+ {
69
+ Method: "pm_validateSponsorshipPolicies"
70
+ Parameters: [
71
+ userOperation: UserOperationWithBigIntAsHex,
72
+ entryPoint: Address,
73
+ sponsorshipPolicyIds: string[]
74
+ ]
75
+ ReturnType: {
76
+ sponsorshipPolicyId: string
77
+ data: {
78
+ name: string | null
79
+ author: string | null
80
+ icon: string | null
81
+ description: string | null
82
+ }
83
+ }[]
64
84
  }
65
85
  ]
@@ -0,0 +1,31 @@
1
+ import type { UserOperation } from "../types"
2
+
3
+ export type GetRequiredPrefundReturnType = {
4
+ userOperation: UserOperation
5
+ }
6
+
7
+ /**
8
+ *
9
+ * Returns the minimum required funds in the senders's smart account to execute the user operation.
10
+ *
11
+ * @param arags: {userOperation} as {@link UserOperation}
12
+ * @returns requiredPrefund as {@link bigint}
13
+ *
14
+ * @example
15
+ * import { getRequiredPrefund } from "permissionless/utils"
16
+ *
17
+ * const requiredPrefund = getRequiredPrefund({
18
+ * userOperation
19
+ * })
20
+ */
21
+ export const getRequiredPrefund = ({
22
+ userOperation
23
+ }: GetRequiredPrefundReturnType): bigint => {
24
+ const multiplier = userOperation.paymasterAndData.length > 2 ? 3n : 1n
25
+ const requiredGas =
26
+ userOperation.callGasLimit +
27
+ userOperation.verificationGasLimit * multiplier +
28
+ userOperation.preVerificationGas
29
+
30
+ return BigInt(requiredGas) * BigInt(userOperation.maxFeePerGas)
31
+ }
package/utils/index.ts CHANGED
@@ -1,4 +1,8 @@
1
1
  import type { Account, Address } from "viem"
2
+ import {
3
+ type GetRequiredPrefundReturnType,
4
+ getRequiredPrefund
5
+ } from "./getRequiredPrefund.js"
2
6
  import {
3
7
  type GetUserOperationHashParams,
4
8
  getUserOperationHash
@@ -16,6 +20,8 @@ export function parseAccount(account: Address | Account): Account {
16
20
 
17
21
  export {
18
22
  getUserOperationHash,
23
+ getRequiredPrefund,
24
+ type GetRequiredPrefundReturnType,
19
25
  type GetUserOperationHashParams,
20
26
  signUserOperationHashWithECDSA,
21
27
  AccountOrClientNotFoundError