permissionless 0.1.9 → 0.1.11

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 (34) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/_cjs/accounts/biconomy/signerToBiconomySmartAccount.js +2 -1
  3. package/_cjs/accounts/biconomy/signerToBiconomySmartAccount.js.map +1 -1
  4. package/_cjs/accounts/safe/signerToSafeSmartAccount.js +122 -68
  5. package/_cjs/accounts/safe/signerToSafeSmartAccount.js.map +1 -1
  6. package/_cjs/errors/sendUserOperation.js +1 -11
  7. package/_cjs/errors/sendUserOperation.js.map +1 -1
  8. package/_cjs/utils/getEntryPointVersion.js +9 -1
  9. package/_cjs/utils/getEntryPointVersion.js.map +1 -1
  10. package/_cjs/utils/getUserOperationHash.js +29 -35
  11. package/_cjs/utils/getUserOperationHash.js.map +1 -1
  12. package/_esm/accounts/biconomy/signerToBiconomySmartAccount.js +2 -1
  13. package/_esm/accounts/biconomy/signerToBiconomySmartAccount.js.map +1 -1
  14. package/_esm/accounts/safe/signerToSafeSmartAccount.js +123 -69
  15. package/_esm/accounts/safe/signerToSafeSmartAccount.js.map +1 -1
  16. package/_esm/errors/sendUserOperation.js +1 -11
  17. package/_esm/errors/sendUserOperation.js.map +1 -1
  18. package/_esm/utils/getEntryPointVersion.js +7 -0
  19. package/_esm/utils/getEntryPointVersion.js.map +1 -1
  20. package/_esm/utils/getUserOperationHash.js +30 -36
  21. package/_esm/utils/getUserOperationHash.js.map +1 -1
  22. package/_types/accounts/biconomy/signerToBiconomySmartAccount.d.ts.map +1 -1
  23. package/_types/accounts/safe/signerToSafeSmartAccount.d.ts +5 -5
  24. package/_types/accounts/safe/signerToSafeSmartAccount.d.ts.map +1 -1
  25. package/_types/errors/sendUserOperation.d.ts.map +1 -1
  26. package/_types/utils/getEntryPointVersion.d.ts +3 -1
  27. package/_types/utils/getEntryPointVersion.d.ts.map +1 -1
  28. package/_types/utils/getUserOperationHash.d.ts.map +1 -1
  29. package/accounts/biconomy/signerToBiconomySmartAccount.ts +4 -3
  30. package/accounts/safe/signerToSafeSmartAccount.ts +182 -102
  31. package/errors/sendUserOperation.ts +1 -11
  32. package/package.json +1 -1
  33. package/utils/getEntryPointVersion.ts +17 -1
  34. package/utils/getUserOperationHash.ts +32 -46
@@ -1,15 +1,15 @@
1
1
  import { type Address, type Chain, type Client, type Transport } from "viem";
2
- import type { ENTRYPOINT_ADDRESS_V06_TYPE, Prettify } from "../../types";
3
- import type { EntryPoint } from "../../types/entrypoint";
2
+ import type { Prettify } from "../../types";
3
+ import type { EntryPoint } from "../../types";
4
4
  import { type SmartAccount, type SmartAccountSigner } from "../types";
5
5
  export type SafeVersion = "1.4.1";
6
- export type SafeSmartAccount<entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE = ENTRYPOINT_ADDRESS_V06_TYPE, transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined> = SmartAccount<entryPoint, "SafeSmartAccount", transport, chain>;
6
+ export type SafeSmartAccount<entryPoint extends EntryPoint, transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined> = SmartAccount<entryPoint, "SafeSmartAccount", transport, chain>;
7
7
  export type SignerToSafeSmartAccountParameters<entryPoint extends EntryPoint, TSource extends string = string, TAddress extends Address = Address> = Prettify<{
8
8
  signer: SmartAccountSigner<TSource, TAddress>;
9
9
  safeVersion: SafeVersion;
10
10
  entryPoint: entryPoint;
11
11
  address?: Address;
12
- addModuleLibAddress?: Address;
12
+ safeModuleSetupAddress?: Address;
13
13
  safe4337ModuleAddress?: Address;
14
14
  safeProxyFactoryAddress?: Address;
15
15
  safeSingletonAddress?: Address;
@@ -30,5 +30,5 @@ export type SignerToSafeSmartAccountParameters<entryPoint extends EntryPoint, TS
30
30
  *
31
31
  * @returns A Private Key Simple Account.
32
32
  */
33
- export declare function signerToSafeSmartAccount<entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TSource extends string = string, TAddress extends Address = Address>(client: Client<TTransport, TChain>, { signer, address, safeVersion, entryPoint: entryPointAddress, addModuleLibAddress: _addModuleLibAddress, safe4337ModuleAddress: _safe4337ModuleAddress, safeProxyFactoryAddress: _safeProxyFactoryAddress, safeSingletonAddress: _safeSingletonAddress, multiSendAddress: _multiSendAddress, multiSendCallOnlyAddress: _multiSendCallOnlyAddress, saltNonce, validUntil, validAfter, safeModules, setupTransactions }: SignerToSafeSmartAccountParameters<entryPoint, TSource, TAddress>): Promise<SafeSmartAccount<entryPoint, TTransport, TChain>>;
33
+ export declare function signerToSafeSmartAccount<entryPoint extends EntryPoint, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TSource extends string = string, TAddress extends Address = Address>(client: Client<TTransport, TChain>, { signer, address, safeVersion, entryPoint: entryPointAddress, safeModuleSetupAddress: _safeModuleSetupAddress, safe4337ModuleAddress: _safe4337ModuleAddress, safeProxyFactoryAddress: _safeProxyFactoryAddress, safeSingletonAddress: _safeSingletonAddress, multiSendAddress: _multiSendAddress, multiSendCallOnlyAddress: _multiSendCallOnlyAddress, saltNonce, validUntil, validAfter, safeModules, setupTransactions }: SignerToSafeSmartAccountParameters<entryPoint, TSource, TAddress>): Promise<SafeSmartAccount<entryPoint, TTransport, TChain>>;
34
34
  //# sourceMappingURL=signerToSafeSmartAccount.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"signerToSafeSmartAccount.d.ts","sourceRoot":"","sources":["../../../accounts/safe/signerToSafeSmartAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,MAAM,EAIX,KAAK,SAAS,EAcjB,MAAM,MAAM,CAAA;AAQb,OAAO,KAAK,EAAE,2BAA2B,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAIxD,OAAO,EAEH,KAAK,YAA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U,EAAE,MAAM,CAAC,EAClC,EACI,MAAM,EACN,OAAO,EACP,WAAW,EACX,UAAU,EAAE,iBAAiB,EAC7B,sBAAsB,EAAE,uBAAuB,EAC/C,qBAAqB,EAAE,sBAAsB,EAC7C,uBAAuB,EAAE,wBAAwB,EACjD,oBAAoB,EAAE,qBAAqB,EAC3C,gBAAgB,EAAE,iBAAiB,EACnC,wBAAwB,EAAE,yBAAyB,EACnD,SAAc,EACd,UAAc,EACd,UAAc,EACd,WAAgB,EAChB,iBAAsB,EACzB,EAAE,kCAAkC,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,GACrE,OAAO,CAAC,gBAAgB,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC,CA4S3D"}
@@ -1 +1 @@
1
- {"version":3,"file":"sendUserOperation.d.ts","sourceRoot":"","sources":["../../errors/sendUserOperation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;AAChC,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,sCAAsC,CAAA;AACvF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAGrD,MAAM,MAAM,0BAA0B,CAAC,UAAU,SAAS,UAAU,IAChE,sBAAsB,CAAC,UAAU,CAAC,GAAG;IACjC,IAAI,EAAE,wBAAwB,CAAA;CACjC,CAAA;AACL,qBAAa,sBAAsB,CAC/B,UAAU,SAAS,UAAU,CAC/B,SAAQ,SAAS;IACN,KAAK,EAAE,SAAS,CAAA;IAEhB,IAAI,SAA2B;gBAGpC,KAAK,EAAE,SAAS,EAChB,EACI,aAAa,EACb,UAAU,EACV,QAAQ,EACX,EAAE,2BAA2B,CAAC,UAAU,CAAC,GAAG;QACzC,QAAQ,CAAC,EAAE,MAAM,CAAA;KACpB;CA4BR"}
1
+ {"version":3,"file":"sendUserOperation.d.ts","sourceRoot":"","sources":["../../errors/sendUserOperation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;AAChC,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,sCAAsC,CAAA;AACvF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAGrD,MAAM,MAAM,0BAA0B,CAAC,UAAU,SAAS,UAAU,IAChE,sBAAsB,CAAC,UAAU,CAAC,GAAG;IACjC,IAAI,EAAE,wBAAwB,CAAA;CACjC,CAAA;AACL,qBAAa,sBAAsB,CAC/B,UAAU,SAAS,UAAU,CAC/B,SAAQ,SAAS;IACN,KAAK,EAAE,SAAS,CAAA;IAEhB,IAAI,SAA2B;gBAGpC,KAAK,EAAE,SAAS,EAChB,EACI,aAAa,EACb,UAAU,EACV,QAAQ,EACX,EAAE,2BAA2B,CAAC,UAAU,CAAC,GAAG;QACzC,QAAQ,CAAC,EAAE,MAAM,CAAA;KACpB;CAkBR"}
@@ -1,6 +1,8 @@
1
- import type { ENTRYPOINT_ADDRESS_V06_TYPE, ENTRYPOINT_ADDRESS_V07_TYPE } from "../types";
1
+ import type { ENTRYPOINT_ADDRESS_V06_TYPE, ENTRYPOINT_ADDRESS_V07_TYPE, UserOperation } from "../types";
2
2
  import type { EntryPoint, GetEntryPointVersion } from "../types/entrypoint";
3
3
  export declare const ENTRYPOINT_ADDRESS_V06: ENTRYPOINT_ADDRESS_V06_TYPE;
4
4
  export declare const ENTRYPOINT_ADDRESS_V07: ENTRYPOINT_ADDRESS_V07_TYPE;
5
5
  export declare const getEntryPointVersion: (entryPoint: EntryPoint) => GetEntryPointVersion<EntryPoint>;
6
+ export declare function isUserOperationVersion06(entryPoint: EntryPoint, _operation: UserOperation<"v0.6"> | UserOperation<"v0.7">): _operation is UserOperation<"v0.6">;
7
+ export declare function isUserOperationVersion07(entryPoint: EntryPoint, _operation: UserOperation<"v0.6"> | UserOperation<"v0.7">): _operation is UserOperation<"v0.7">;
6
8
  //# sourceMappingURL=getEntryPointVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getEntryPointVersion.d.ts","sourceRoot":"","sources":["../../utils/getEntryPointVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,2BAA2B,EAC3B,2BAA2B,EAC9B,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAE3E,eAAO,MAAM,sBAAsB,EAAE,2BACW,CAAA;AAChD,eAAO,MAAM,sBAAsB,EAAE,2BACW,CAAA;AAEhD,eAAO,MAAM,oBAAoB,eACjB,UAAU,KACvB,qBAAqB,UAAU,CACyB,CAAA"}
1
+ {"version":3,"file":"getEntryPointVersion.d.ts","sourceRoot":"","sources":["../../utils/getEntryPointVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,2BAA2B,EAC3B,2BAA2B,EAC3B,aAAa,EAChB,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAE3E,eAAO,MAAM,sBAAsB,EAAE,2BACW,CAAA;AAChD,eAAO,MAAM,sBAAsB,EAAE,2BACW,CAAA;AAEhD,eAAO,MAAM,oBAAoB,eACjB,UAAU,KACvB,qBAAqB,UAAU,CACyB,CAAA;AAE3D,wBAAgB,wBAAwB,CACpC,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,GAC1D,UAAU,IAAI,aAAa,CAAC,MAAM,CAAC,CAErC;AAGD,wBAAgB,wBAAwB,CACpC,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,GAC1D,UAAU,IAAI,aAAa,CAAC,MAAM,CAAC,CAErC"}
@@ -1 +1 @@
1
- {"version":3,"file":"getUserOperationHash.d.ts","sourceRoot":"","sources":["../../utils/getUserOperationHash.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,IAAI,EAAO,MAAM,MAAM,CAAA;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAmH3D,MAAM,MAAM,0BAA0B,CAAC,UAAU,SAAS,UAAU,IAAI;IACpE,aAAa,EAAE,aAAa,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAA;IAC9D,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;CAClB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,oBAAoB,wIAIW,IAgB3C,CAAA"}
1
+ {"version":3,"file":"getUserOperationHash.d.ts","sourceRoot":"","sources":["../../utils/getUserOperationHash.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,IAAI,EAAO,MAAM,MAAM,CAAA;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAqG3D,MAAM,MAAM,0BAA0B,CAAC,UAAU,SAAS,UAAU,IAAI;IACpE,aAAa,EAAE,aAAa,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAA;IAC9D,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;CAClB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,oBAAoB,wIAIW,IAgB3C,CAAA"}
@@ -272,18 +272,19 @@ export async function signerToBiconomySmartAccount<
272
272
  return toSmartAccount({
273
273
  address: accountAddress,
274
274
  async signMessage({ message }) {
275
- let signature = await signMessage(client, {
275
+ let signature: Hex = await signMessage(client, {
276
276
  account: viemSigner,
277
277
  message
278
278
  })
279
279
  const potentiallyIncorrectV = parseInt(signature.slice(-2), 16)
280
280
  if (![27, 28].includes(potentiallyIncorrectV)) {
281
281
  const correctV = potentiallyIncorrectV + 27
282
- signature = signature.slice(0, -2) + correctV.toString(16)
282
+ signature = (signature.slice(0, -2) +
283
+ correctV.toString(16)) as Hex
283
284
  }
284
285
  return encodeAbiParameters(
285
286
  [{ type: "bytes" }, { type: "address" }],
286
- [signature as Hex, ecdsaModuleAddress]
287
+ [signature, ecdsaModuleAddress]
287
288
  )
288
289
  },
289
290
  async signTransaction(_, __) {
@@ -17,7 +17,9 @@ import {
17
17
  hashTypedData,
18
18
  hexToBigInt,
19
19
  keccak256,
20
+ pad,
20
21
  toBytes,
22
+ toHex,
21
23
  zeroAddress
22
24
  } from "viem"
23
25
  import {
@@ -27,9 +29,17 @@ import {
27
29
  signTypedData
28
30
  } from "viem/actions"
29
31
  import { getAccountNonce } from "../../actions/public/getAccountNonce"
30
- import type { ENTRYPOINT_ADDRESS_V06_TYPE, Prettify } from "../../types"
31
- import type { EntryPoint } from "../../types/entrypoint"
32
- import { getEntryPointVersion } from "../../utils"
32
+ import type {
33
+ EntryPointVersion,
34
+ GetEntryPointVersion,
35
+ Prettify
36
+ } from "../../types"
37
+ import type { EntryPoint, UserOperation } from "../../types"
38
+ import {
39
+ getEntryPointVersion,
40
+ isUserOperationVersion06,
41
+ isUserOperationVersion07
42
+ } from "../../utils/getEntryPointVersion"
33
43
  import { isSmartAccountDeployed } from "../../utils/isSmartAccountDeployed"
34
44
  import { toSmartAccount } from "../toSmartAccount"
35
45
  import {
@@ -40,7 +50,7 @@ import {
40
50
 
41
51
  export type SafeVersion = "1.4.1"
42
52
 
43
- const EIP712_SAFE_OPERATION_TYPE = {
53
+ const EIP712_SAFE_OPERATION_TYPE_V06 = {
44
54
  SafeOp: [
45
55
  { type: "address", name: "safe" },
46
56
  { type: "uint256", name: "nonce" },
@@ -58,25 +68,63 @@ const EIP712_SAFE_OPERATION_TYPE = {
58
68
  ]
59
69
  }
60
70
 
71
+ const EIP712_SAFE_OPERATION_TYPE_V07 = {
72
+ SafeOp: [
73
+ { type: "address", name: "safe" },
74
+ { type: "uint256", name: "nonce" },
75
+ { type: "bytes", name: "initCode" },
76
+ { type: "bytes", name: "callData" },
77
+ { type: "uint128", name: "verificationGasLimit" },
78
+ { type: "uint128", name: "callGasLimit" },
79
+ { type: "uint256", name: "preVerificationGas" },
80
+ { type: "uint128", name: "maxPriorityFeePerGas" },
81
+ { type: "uint128", name: "maxFeePerGas" },
82
+ { type: "bytes", name: "paymasterAndData" },
83
+ { type: "uint48", name: "validAfter" },
84
+ { type: "uint48", name: "validUntil" },
85
+ { type: "address", name: "entryPoint" }
86
+ ]
87
+ }
88
+
61
89
  const SAFE_VERSION_TO_ADDRESSES_MAP: {
62
90
  [key in SafeVersion]: {
63
- ADD_MODULES_LIB_ADDRESS: Address
64
- SAFE_4337_MODULE_ADDRESS: Address
65
- SAFE_PROXY_FACTORY_ADDRESS: Address
66
- SAFE_SINGLETON_ADDRESS: Address
67
- MULTI_SEND_ADDRESS: Address
68
- MULTI_SEND_CALL_ONLY_ADDRESS: Address
91
+ [key in EntryPointVersion]: {
92
+ SAFE_MODULE_SETUP_ADDRESS: Address
93
+ SAFE_4337_MODULE_ADDRESS: Address
94
+ SAFE_PROXY_FACTORY_ADDRESS: Address
95
+ SAFE_SINGLETON_ADDRESS: Address
96
+ MULTI_SEND_ADDRESS: Address
97
+ MULTI_SEND_CALL_ONLY_ADDRESS: Address
98
+ }
69
99
  }
70
100
  } = {
71
101
  "1.4.1": {
72
- ADD_MODULES_LIB_ADDRESS: "0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb",
73
- SAFE_4337_MODULE_ADDRESS: "0xa581c4A4DB7175302464fF3C06380BC3270b4037",
74
- SAFE_PROXY_FACTORY_ADDRESS:
75
- "0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67",
76
- SAFE_SINGLETON_ADDRESS: "0x41675C099F32341bf84BFc5382aF534df5C7461a",
77
- MULTI_SEND_ADDRESS: "0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",
78
- MULTI_SEND_CALL_ONLY_ADDRESS:
79
- "0x9641d764fc13c8B624c04430C7356C1C7C8102e2"
102
+ "v0.6": {
103
+ SAFE_MODULE_SETUP_ADDRESS:
104
+ "0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb",
105
+ SAFE_4337_MODULE_ADDRESS:
106
+ "0xa581c4A4DB7175302464fF3C06380BC3270b4037",
107
+ SAFE_PROXY_FACTORY_ADDRESS:
108
+ "0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67",
109
+ SAFE_SINGLETON_ADDRESS:
110
+ "0x41675C099F32341bf84BFc5382aF534df5C7461a",
111
+ MULTI_SEND_ADDRESS: "0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",
112
+ MULTI_SEND_CALL_ONLY_ADDRESS:
113
+ "0x9641d764fc13c8B624c04430C7356C1C7C8102e2"
114
+ },
115
+ "v0.7": {
116
+ SAFE_MODULE_SETUP_ADDRESS:
117
+ "0x2dd68b007B46fBe91B9A7c3EDa5A7a1063cB5b47",
118
+ SAFE_4337_MODULE_ADDRESS:
119
+ "0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226",
120
+ SAFE_PROXY_FACTORY_ADDRESS:
121
+ "0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67",
122
+ SAFE_SINGLETON_ADDRESS:
123
+ "0x41675C099F32341bf84BFc5382aF534df5C7461a",
124
+ MULTI_SEND_ADDRESS: "0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",
125
+ MULTI_SEND_CALL_ONLY_ADDRESS:
126
+ "0x9641d764fc13c8B624c04430C7356C1C7C8102e2"
127
+ }
80
128
  }
81
129
  }
82
130
 
@@ -174,22 +222,21 @@ const encodeMultiSend = (
174
222
  }
175
223
 
176
224
  export type SafeSmartAccount<
177
- entryPoint extends
178
- ENTRYPOINT_ADDRESS_V06_TYPE = ENTRYPOINT_ADDRESS_V06_TYPE,
225
+ entryPoint extends EntryPoint,
179
226
  transport extends Transport = Transport,
180
227
  chain extends Chain | undefined = Chain | undefined
181
228
  > = SmartAccount<entryPoint, "SafeSmartAccount", transport, chain>
182
229
 
183
230
  const getInitializerCode = async ({
184
231
  owner,
185
- addModuleLibAddress,
232
+ safeModuleSetupAddress,
186
233
  safe4337ModuleAddress,
187
234
  multiSendAddress,
188
235
  setupTransactions = [],
189
236
  safeModules = []
190
237
  }: {
191
238
  owner: Address
192
- addModuleLibAddress: Address
239
+ safeModuleSetupAddress: Address
193
240
  safe4337ModuleAddress: Address
194
241
  multiSendAddress: Address
195
242
  setupTransactions?: {
@@ -201,7 +248,7 @@ const getInitializerCode = async ({
201
248
  }) => {
202
249
  const multiSendCallData = encodeMultiSend([
203
250
  {
204
- to: addModuleLibAddress,
251
+ to: safeModuleSetupAddress,
205
252
  data: encodeFunctionData({
206
253
  abi: [
207
254
  {
@@ -292,9 +339,29 @@ const getInitializerCode = async ({
292
339
  })
293
340
  }
294
341
 
342
+ function getPaymasterAndData(unpackedUserOperation: UserOperation<"v0.7">) {
343
+ return unpackedUserOperation.paymaster
344
+ ? concat([
345
+ unpackedUserOperation.paymaster,
346
+ pad(
347
+ toHex(
348
+ unpackedUserOperation.paymasterVerificationGasLimit || 0n
349
+ ),
350
+ {
351
+ size: 16
352
+ }
353
+ ),
354
+ pad(toHex(unpackedUserOperation.paymasterPostOpGasLimit || 0n), {
355
+ size: 16
356
+ }),
357
+ unpackedUserOperation.paymasterData || ("0x" as Hex)
358
+ ])
359
+ : "0x"
360
+ }
361
+
295
362
  const getAccountInitCode = async ({
296
363
  owner,
297
- addModuleLibAddress,
364
+ safeModuleSetupAddress,
298
365
  safe4337ModuleAddress,
299
366
  safeSingletonAddress,
300
367
  multiSendAddress,
@@ -303,7 +370,7 @@ const getAccountInitCode = async ({
303
370
  safeModules = []
304
371
  }: {
305
372
  owner: Address
306
- addModuleLibAddress: Address
373
+ safeModuleSetupAddress: Address
307
374
  safe4337ModuleAddress: Address
308
375
  safeSingletonAddress: Address
309
376
  multiSendAddress: Address
@@ -318,7 +385,7 @@ const getAccountInitCode = async ({
318
385
  if (!owner) throw new Error("Owner account not found")
319
386
  const initializer = await getInitializerCode({
320
387
  owner,
321
- addModuleLibAddress,
388
+ safeModuleSetupAddress,
322
389
  safe4337ModuleAddress,
323
390
  multiSendAddress,
324
391
  setupTransactions,
@@ -370,7 +437,7 @@ const getAccountAddress = async <
370
437
  >({
371
438
  client,
372
439
  owner,
373
- addModuleLibAddress,
440
+ safeModuleSetupAddress,
374
441
  safe4337ModuleAddress,
375
442
  safeProxyFactoryAddress,
376
443
  safeSingletonAddress,
@@ -381,7 +448,7 @@ const getAccountAddress = async <
381
448
  }: {
382
449
  client: Client<TTransport, TChain>
383
450
  owner: Address
384
- addModuleLibAddress: Address
451
+ safeModuleSetupAddress: Address
385
452
  safe4337ModuleAddress: Address
386
453
  safeProxyFactoryAddress: Address
387
454
  safeSingletonAddress: Address
@@ -421,7 +488,7 @@ const getAccountAddress = async <
421
488
 
422
489
  const initializer = await getInitializerCode({
423
490
  owner,
424
- addModuleLibAddress,
491
+ safeModuleSetupAddress,
425
492
  safe4337ModuleAddress,
426
493
  multiSendAddress,
427
494
  setupTransactions,
@@ -445,8 +512,10 @@ const getAccountAddress = async <
445
512
 
446
513
  const getDefaultAddresses = (
447
514
  safeVersion: SafeVersion,
515
+ entryPointAddress: EntryPoint,
448
516
  {
449
517
  addModuleLibAddress: _addModuleLibAddress,
518
+ safeModuleSetupAddress: _safeModuleSetupAddress,
450
519
  safe4337ModuleAddress: _safe4337ModuleAddress,
451
520
  safeProxyFactoryAddress: _safeProxyFactoryAddress,
452
521
  safeSingletonAddress: _safeSingletonAddress,
@@ -454,6 +523,7 @@ const getDefaultAddresses = (
454
523
  multiSendCallOnlyAddress: _multiSendCallOnlyAddress
455
524
  }: {
456
525
  addModuleLibAddress?: Address
526
+ safeModuleSetupAddress?: Address
457
527
  safe4337ModuleAddress?: Address
458
528
  safeProxyFactoryAddress?: Address
459
529
  safeSingletonAddress?: Address
@@ -461,28 +531,38 @@ const getDefaultAddresses = (
461
531
  multiSendCallOnlyAddress?: Address
462
532
  }
463
533
  ) => {
464
- const addModuleLibAddress =
534
+ const entryPointVersion = getEntryPointVersion(entryPointAddress)
535
+
536
+ const safeModuleSetupAddress =
537
+ _safeModuleSetupAddress ??
465
538
  _addModuleLibAddress ??
466
- SAFE_VERSION_TO_ADDRESSES_MAP[safeVersion].ADD_MODULES_LIB_ADDRESS
539
+ SAFE_VERSION_TO_ADDRESSES_MAP[safeVersion][entryPointVersion]
540
+ .SAFE_MODULE_SETUP_ADDRESS
467
541
  const safe4337ModuleAddress =
468
542
  _safe4337ModuleAddress ??
469
- SAFE_VERSION_TO_ADDRESSES_MAP[safeVersion].SAFE_4337_MODULE_ADDRESS
543
+ SAFE_VERSION_TO_ADDRESSES_MAP[safeVersion][entryPointVersion]
544
+ .SAFE_4337_MODULE_ADDRESS
470
545
  const safeProxyFactoryAddress =
471
546
  _safeProxyFactoryAddress ??
472
- SAFE_VERSION_TO_ADDRESSES_MAP[safeVersion].SAFE_PROXY_FACTORY_ADDRESS
547
+ SAFE_VERSION_TO_ADDRESSES_MAP[safeVersion][entryPointVersion]
548
+ .SAFE_PROXY_FACTORY_ADDRESS
473
549
  const safeSingletonAddress =
474
550
  _safeSingletonAddress ??
475
- SAFE_VERSION_TO_ADDRESSES_MAP[safeVersion].SAFE_SINGLETON_ADDRESS
551
+ SAFE_VERSION_TO_ADDRESSES_MAP[safeVersion][entryPointVersion]
552
+ .SAFE_SINGLETON_ADDRESS
476
553
  const multiSendAddress =
477
554
  _multiSendAddress ??
478
- SAFE_VERSION_TO_ADDRESSES_MAP[safeVersion].MULTI_SEND_ADDRESS
555
+ SAFE_VERSION_TO_ADDRESSES_MAP[safeVersion][entryPointVersion]
556
+ .MULTI_SEND_ADDRESS
479
557
 
480
558
  const multiSendCallOnlyAddress =
481
559
  _multiSendCallOnlyAddress ??
482
- SAFE_VERSION_TO_ADDRESSES_MAP[safeVersion].MULTI_SEND_CALL_ONLY_ADDRESS
560
+ SAFE_VERSION_TO_ADDRESSES_MAP[safeVersion][
561
+ getEntryPointVersion(entryPointAddress)
562
+ ].MULTI_SEND_CALL_ONLY_ADDRESS
483
563
 
484
564
  return {
485
- addModuleLibAddress,
565
+ safeModuleSetupAddress,
486
566
  safe4337ModuleAddress,
487
567
  safeProxyFactoryAddress,
488
568
  safeSingletonAddress,
@@ -500,7 +580,7 @@ export type SignerToSafeSmartAccountParameters<
500
580
  safeVersion: SafeVersion
501
581
  entryPoint: entryPoint
502
582
  address?: Address
503
- addModuleLibAddress?: Address
583
+ safeModuleSetupAddress?: Address
504
584
  safe4337ModuleAddress?: Address
505
585
  safeProxyFactoryAddress?: Address
506
586
  safeSingletonAddress?: Address
@@ -523,7 +603,7 @@ export type SignerToSafeSmartAccountParameters<
523
603
  * @returns A Private Key Simple Account.
524
604
  */
525
605
  export async function signerToSafeSmartAccount<
526
- entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE,
606
+ entryPoint extends EntryPoint,
527
607
  TTransport extends Transport = Transport,
528
608
  TChain extends Chain | undefined = Chain | undefined,
529
609
  TSource extends string = string,
@@ -535,7 +615,7 @@ export async function signerToSafeSmartAccount<
535
615
  address,
536
616
  safeVersion,
537
617
  entryPoint: entryPointAddress,
538
- addModuleLibAddress: _addModuleLibAddress,
618
+ safeModuleSetupAddress: _safeModuleSetupAddress,
539
619
  safe4337ModuleAddress: _safe4337ModuleAddress,
540
620
  safeProxyFactoryAddress: _safeProxyFactoryAddress,
541
621
  safeSingletonAddress: _safeSingletonAddress,
@@ -548,12 +628,6 @@ export async function signerToSafeSmartAccount<
548
628
  setupTransactions = []
549
629
  }: SignerToSafeSmartAccountParameters<entryPoint, TSource, TAddress>
550
630
  ): Promise<SafeSmartAccount<entryPoint, TTransport, TChain>> {
551
- const entryPointVersion = getEntryPointVersion(entryPointAddress)
552
-
553
- if (entryPointVersion !== "v0.6") {
554
- throw new Error("Only EntryPoint 0.6 is supported")
555
- }
556
-
557
631
  const chainId = await getChainId(client)
558
632
 
559
633
  const viemSigner: LocalAccount = {
@@ -564,14 +638,14 @@ export async function signerToSafeSmartAccount<
564
638
  } as LocalAccount
565
639
 
566
640
  const {
567
- addModuleLibAddress,
641
+ safeModuleSetupAddress,
568
642
  safe4337ModuleAddress,
569
643
  safeProxyFactoryAddress,
570
644
  safeSingletonAddress,
571
645
  multiSendAddress,
572
646
  multiSendCallOnlyAddress
573
- } = getDefaultAddresses(safeVersion, {
574
- addModuleLibAddress: _addModuleLibAddress,
647
+ } = getDefaultAddresses(safeVersion, entryPointAddress, {
648
+ safeModuleSetupAddress: _safeModuleSetupAddress,
575
649
  safe4337ModuleAddress: _safe4337ModuleAddress,
576
650
  safeProxyFactoryAddress: _safeProxyFactoryAddress,
577
651
  safeSingletonAddress: _safeSingletonAddress,
@@ -584,7 +658,7 @@ export async function signerToSafeSmartAccount<
584
658
  (await getAccountAddress<TTransport, TChain>({
585
659
  client,
586
660
  owner: viemSigner.address,
587
- addModuleLibAddress,
661
+ safeModuleSetupAddress,
588
662
  safe4337ModuleAddress,
589
663
  safeProxyFactoryAddress,
590
664
  safeSingletonAddress,
@@ -666,7 +740,44 @@ export async function signerToSafeSmartAccount<
666
740
  entryPoint: entryPointAddress
667
741
  })
668
742
  },
669
- async signUserOperation(userOperation) {
743
+ async signUserOperation(
744
+ userOperation: UserOperation<GetEntryPointVersion<entryPoint>>
745
+ ) {
746
+ const message = {
747
+ safe: accountAddress,
748
+ callData: userOperation.callData,
749
+ nonce: userOperation.nonce,
750
+ initCode: userOperation.initCode ?? "0x",
751
+ maxFeePerGas: userOperation.maxFeePerGas,
752
+ maxPriorityFeePerGas: userOperation.maxPriorityFeePerGas,
753
+ preVerificationGas: userOperation.preVerificationGas,
754
+ verificationGasLimit: userOperation.verificationGasLimit,
755
+ callGasLimit: userOperation.callGasLimit,
756
+ paymasterAndData: userOperation.paymasterAndData ?? "0x",
757
+ validAfter: validAfter,
758
+ validUntil: validUntil,
759
+ entryPoint: entryPointAddress
760
+ }
761
+
762
+ if (
763
+ isUserOperationVersion06(entryPointAddress, userOperation)
764
+ ) {
765
+ message.paymasterAndData = userOperation.paymasterAndData
766
+ }
767
+
768
+ if (
769
+ isUserOperationVersion07(entryPointAddress, userOperation)
770
+ ) {
771
+ if (userOperation.factory && userOperation.factoryData) {
772
+ message.initCode = concatHex([
773
+ userOperation.factory,
774
+ userOperation.factoryData
775
+ ])
776
+ }
777
+ message.paymasterAndData =
778
+ getPaymasterAndData(userOperation)
779
+ }
780
+
670
781
  const signatures = [
671
782
  {
672
783
  signer: viemSigner.address,
@@ -676,27 +787,13 @@ export async function signerToSafeSmartAccount<
676
787
  chainId: chainId,
677
788
  verifyingContract: safe4337ModuleAddress
678
789
  },
679
- types: EIP712_SAFE_OPERATION_TYPE,
790
+ types:
791
+ getEntryPointVersion(entryPointAddress) ===
792
+ "v0.6"
793
+ ? EIP712_SAFE_OPERATION_TYPE_V06
794
+ : EIP712_SAFE_OPERATION_TYPE_V07,
680
795
  primaryType: "SafeOp",
681
- message: {
682
- safe: accountAddress,
683
- callData: userOperation.callData,
684
- entryPoint: entryPointAddress,
685
- nonce: userOperation.nonce,
686
- initCode: userOperation.initCode,
687
- maxFeePerGas: userOperation.maxFeePerGas,
688
- maxPriorityFeePerGas:
689
- userOperation.maxPriorityFeePerGas,
690
- preVerificationGas:
691
- userOperation.preVerificationGas,
692
- verificationGasLimit:
693
- userOperation.verificationGasLimit,
694
- callGasLimit: userOperation.callGasLimit,
695
- paymasterAndData:
696
- userOperation.paymasterAndData,
697
- validAfter: validAfter,
698
- validUntil: validUntil
699
- }
796
+ message: message
700
797
  })
701
798
  }
702
799
  ]
@@ -715,53 +812,36 @@ export async function signerToSafeSmartAccount<
715
812
  )
716
813
  },
717
814
  async getInitCode() {
718
- if (safeDeployed) return "0x"
719
-
720
- safeDeployed = await isSmartAccountDeployed(
721
- client,
722
- accountAddress
723
- )
815
+ safeDeployed =
816
+ safeDeployed ||
817
+ (await isSmartAccountDeployed(client, accountAddress))
724
818
 
725
819
  if (safeDeployed) return "0x"
726
820
 
727
- const initCodeCallData = await getAccountInitCode({
728
- owner: viemSigner.address,
729
- addModuleLibAddress,
730
- safe4337ModuleAddress,
731
- safeSingletonAddress,
732
- multiSendAddress,
733
- saltNonce,
734
- setupTransactions,
735
- safeModules
736
- })
737
-
738
- return concatHex([safeProxyFactoryAddress, initCodeCallData])
821
+ return concatHex([
822
+ (await this.getFactory()) ?? "0x",
823
+ (await this.getFactoryData()) ?? "0x"
824
+ ])
739
825
  },
740
826
  async getFactory() {
741
- if (safeDeployed) return undefined
742
-
743
- safeDeployed = await isSmartAccountDeployed(
744
- client,
745
- accountAddress
746
- )
827
+ safeDeployed =
828
+ safeDeployed ||
829
+ (await isSmartAccountDeployed(client, accountAddress))
747
830
 
748
831
  if (safeDeployed) return undefined
749
832
 
750
833
  return safeProxyFactoryAddress
751
834
  },
752
835
  async getFactoryData() {
753
- if (safeDeployed) return undefined
754
-
755
- safeDeployed = await isSmartAccountDeployed(
756
- client,
757
- accountAddress
758
- )
836
+ safeDeployed =
837
+ safeDeployed ||
838
+ (await isSmartAccountDeployed(client, accountAddress))
759
839
 
760
840
  if (safeDeployed) return undefined
761
841
 
762
842
  return await getAccountInitCode({
763
843
  owner: viemSigner.address,
764
- addModuleLibAddress,
844
+ safeModuleSetupAddress,
765
845
  safe4337ModuleAddress,
766
846
  safeSingletonAddress,
767
847
  multiSendAddress,
@@ -25,17 +25,7 @@ export class SendUserOperationError<
25
25
  }
26
26
  ) {
27
27
  const prettyArgs = prettyPrint({
28
- sender: userOperation.sender,
29
- nonce: userOperation.nonce,
30
- initCode: userOperation.initCode,
31
- callData: userOperation.callData,
32
- callGasLimit: userOperation.callGasLimit,
33
- verificationGasLimit: userOperation.verificationGasLimit,
34
- preVerificationGas: userOperation.preVerificationGas,
35
- maxFeePerGas: userOperation.maxFeePerGas,
36
- maxPriorityFeePerGas: userOperation.maxPriorityFeePerGas,
37
- paymasterAndData: userOperation.paymasterAndData,
38
- signature: userOperation.signature,
28
+ ...userOperation,
39
29
  entryPoint
40
30
  })
41
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "permissionless",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "author": "Pimlico",
5
5
  "homepage": "https://docs.pimlico.io/permissionless",
6
6
  "repository": "github:pimlicolabs/permissionless.js",
@@ -1,6 +1,7 @@
1
1
  import type {
2
2
  ENTRYPOINT_ADDRESS_V06_TYPE,
3
- ENTRYPOINT_ADDRESS_V07_TYPE
3
+ ENTRYPOINT_ADDRESS_V07_TYPE,
4
+ UserOperation
4
5
  } from "../types"
5
6
  import type { EntryPoint, GetEntryPointVersion } from "../types/entrypoint"
6
7
 
@@ -13,3 +14,18 @@ export const getEntryPointVersion = (
13
14
  entryPoint: EntryPoint
14
15
  ): GetEntryPointVersion<EntryPoint> =>
15
16
  entryPoint === ENTRYPOINT_ADDRESS_V06 ? "v0.6" : "v0.7"
17
+
18
+ export function isUserOperationVersion06(
19
+ entryPoint: EntryPoint,
20
+ _operation: UserOperation<"v0.6"> | UserOperation<"v0.7">
21
+ ): _operation is UserOperation<"v0.6"> {
22
+ return getEntryPointVersion(entryPoint) === "v0.6"
23
+ }
24
+
25
+ // Type predicate to check if the UserOperation is V07.
26
+ export function isUserOperationVersion07(
27
+ entryPoint: EntryPoint,
28
+ _operation: UserOperation<"v0.6"> | UserOperation<"v0.7">
29
+ ): _operation is UserOperation<"v0.7"> {
30
+ return getEntryPointVersion(entryPoint) === "v0.7"
31
+ }