permissionless 0.2.22 → 0.2.24

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 (96) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/_cjs/accounts/etherspot/abi/EtherspotBootstrapAbi.js +97 -0
  3. package/_cjs/accounts/etherspot/abi/EtherspotBootstrapAbi.js.map +1 -0
  4. package/_cjs/accounts/etherspot/constants.js +20 -0
  5. package/_cjs/accounts/etherspot/constants.js.map +1 -0
  6. package/_cjs/accounts/etherspot/toEtherspotSmartAccount.js +186 -0
  7. package/_cjs/accounts/etherspot/toEtherspotSmartAccount.js.map +1 -0
  8. package/_cjs/accounts/etherspot/utils/getInitMSAData.js +46 -0
  9. package/_cjs/accounts/etherspot/utils/getInitMSAData.js.map +1 -0
  10. package/_cjs/accounts/etherspot/utils/getNonceKey.js +19 -0
  11. package/_cjs/accounts/etherspot/utils/getNonceKey.js.map +1 -0
  12. package/_cjs/accounts/etherspot/utils/wrapMessageHash.js +22 -0
  13. package/_cjs/accounts/etherspot/utils/wrapMessageHash.js.map +1 -0
  14. package/_cjs/accounts/index.js +3 -1
  15. package/_cjs/accounts/index.js.map +1 -1
  16. package/_cjs/accounts/safe/index.js +11 -0
  17. package/_cjs/accounts/safe/index.js.map +1 -0
  18. package/_cjs/accounts/safe/signUserOperation.js +97 -0
  19. package/_cjs/accounts/safe/signUserOperation.js.map +1 -0
  20. package/_cjs/accounts/safe/toSafeSmartAccount.js +111 -89
  21. package/_cjs/accounts/safe/toSafeSmartAccount.js.map +1 -1
  22. package/_cjs/actions/etherspot/getUserOperationGasPrice.js +15 -0
  23. package/_cjs/actions/etherspot/getUserOperationGasPrice.js.map +1 -0
  24. package/_cjs/actions/etherspot.js +6 -0
  25. package/_cjs/actions/etherspot.js.map +1 -0
  26. package/_cjs/types/etherspot.js +3 -0
  27. package/_cjs/types/etherspot.js.map +1 -0
  28. package/_esm/accounts/etherspot/abi/EtherspotBootstrapAbi.js +94 -0
  29. package/_esm/accounts/etherspot/abi/EtherspotBootstrapAbi.js.map +1 -0
  30. package/_esm/accounts/etherspot/constants.js +17 -0
  31. package/_esm/accounts/etherspot/constants.js.map +1 -0
  32. package/_esm/accounts/etherspot/toEtherspotSmartAccount.js +212 -0
  33. package/_esm/accounts/etherspot/toEtherspotSmartAccount.js.map +1 -0
  34. package/_esm/accounts/etherspot/utils/getInitMSAData.js +42 -0
  35. package/_esm/accounts/etherspot/utils/getInitMSAData.js.map +1 -0
  36. package/_esm/accounts/etherspot/utils/getNonceKey.js +15 -0
  37. package/_esm/accounts/etherspot/utils/getNonceKey.js.map +1 -0
  38. package/_esm/accounts/etherspot/utils/wrapMessageHash.js +18 -0
  39. package/_esm/accounts/etherspot/utils/wrapMessageHash.js.map +1 -0
  40. package/_esm/accounts/index.js +2 -1
  41. package/_esm/accounts/index.js.map +1 -1
  42. package/_esm/accounts/safe/index.js +8 -0
  43. package/_esm/accounts/safe/index.js.map +1 -0
  44. package/_esm/accounts/safe/signUserOperation.js +94 -0
  45. package/_esm/accounts/safe/signUserOperation.js.map +1 -0
  46. package/_esm/accounts/safe/toSafeSmartAccount.js +112 -92
  47. package/_esm/accounts/safe/toSafeSmartAccount.js.map +1 -1
  48. package/_esm/actions/etherspot/getUserOperationGasPrice.js +17 -0
  49. package/_esm/actions/etherspot/getUserOperationGasPrice.js.map +1 -0
  50. package/_esm/actions/etherspot.js +3 -0
  51. package/_esm/actions/etherspot.js.map +1 -0
  52. package/_esm/types/etherspot.js +2 -0
  53. package/_esm/types/etherspot.js.map +1 -0
  54. package/_types/accounts/etherspot/abi/EtherspotBootstrapAbi.d.ts +28 -0
  55. package/_types/accounts/etherspot/abi/EtherspotBootstrapAbi.d.ts.map +1 -0
  56. package/_types/accounts/etherspot/constants.d.ts +18 -0
  57. package/_types/accounts/etherspot/constants.d.ts.map +1 -0
  58. package/_types/accounts/etherspot/toEtherspotSmartAccount.d.ts +24 -0
  59. package/_types/accounts/etherspot/toEtherspotSmartAccount.d.ts.map +1 -0
  60. package/_types/accounts/etherspot/utils/getInitMSAData.d.ts +3 -0
  61. package/_types/accounts/etherspot/utils/getInitMSAData.d.ts.map +1 -0
  62. package/_types/accounts/etherspot/utils/getNonceKey.d.ts +3 -0
  63. package/_types/accounts/etherspot/utils/getNonceKey.d.ts.map +1 -0
  64. package/_types/accounts/etherspot/utils/wrapMessageHash.d.ts +8 -0
  65. package/_types/accounts/etherspot/utils/wrapMessageHash.d.ts.map +1 -0
  66. package/_types/accounts/index.d.ts +2 -1
  67. package/_types/accounts/index.d.ts.map +1 -1
  68. package/_types/accounts/safe/index.d.ts +8 -0
  69. package/_types/accounts/safe/index.d.ts.map +1 -0
  70. package/_types/accounts/safe/signUserOperation.d.ts +19 -0
  71. package/_types/accounts/safe/signUserOperation.d.ts.map +1 -0
  72. package/_types/accounts/safe/toSafeSmartAccount.d.ts +33 -6
  73. package/_types/accounts/safe/toSafeSmartAccount.d.ts.map +1 -1
  74. package/_types/actions/etherspot/getUserOperationGasPrice.d.ts +14 -0
  75. package/_types/actions/etherspot/getUserOperationGasPrice.d.ts.map +1 -0
  76. package/_types/actions/etherspot.d.ts +3 -0
  77. package/_types/actions/etherspot.d.ts.map +1 -0
  78. package/_types/types/etherspot.d.ts +13 -0
  79. package/_types/types/etherspot.d.ts.map +1 -0
  80. package/accounts/etherspot/abi/EtherspotBootstrapAbi.ts +94 -0
  81. package/accounts/etherspot/constants.ts +27 -0
  82. package/accounts/etherspot/toEtherspotSmartAccount.ts +360 -0
  83. package/accounts/etherspot/utils/getInitMSAData.ts +56 -0
  84. package/accounts/etherspot/utils/getNonceKey.ts +21 -0
  85. package/accounts/etherspot/utils/wrapMessageHash.ts +42 -0
  86. package/accounts/index.ts +12 -1
  87. package/accounts/safe/index.ts +22 -0
  88. package/accounts/safe/signUserOperation.test.ts +277 -0
  89. package/accounts/safe/signUserOperation.ts +177 -0
  90. package/accounts/safe/toSafeSmartAccount.ts +177 -116
  91. package/actions/etherspot/getUserOperationGasPrice.ts +32 -0
  92. package/actions/etherspot.ts +6 -0
  93. package/actions/smartAccount/signMessage.test.ts +27 -7
  94. package/actions/smartAccount/signTypedData.test.ts +4 -1
  95. package/package.json +11 -1
  96. package/types/etherspot.ts +12 -0
@@ -0,0 +1,212 @@
1
+ import { encodeAbiParameters, encodeFunctionData, encodePacked, toHex, zeroAddress } from "viem";
2
+ import { entryPoint07Abi, entryPoint07Address, getUserOperationHash, toSmartAccount } from "viem/account-abstraction";
3
+ import { getChainId } from "viem/actions";
4
+ import { getAction } from "viem/utils";
5
+ import { getAccountNonce } from "../../actions/public/getAccountNonce.js";
6
+ import { getSenderAddress } from "../../actions/public/getSenderAddress.js";
7
+ import { encode7579Calls } from "../../utils/encode7579Calls.js";
8
+ import { toOwner } from "../../utils/index.js";
9
+ import { DEFAULT_CONTRACT_ADDRESS, DUMMY_ECDSA_SIGNATURE } from "./constants.js";
10
+ import { getInitMSAData } from "./utils/getInitMSAData.js";
11
+ import { getNonceKeyWithEncoding } from "./utils/getNonceKey.js";
12
+ /**
13
+ * The account creation ABI for a modular etherspot smart account
14
+ */
15
+ const createAccountAbi = [
16
+ {
17
+ inputs: [
18
+ {
19
+ internalType: "bytes32",
20
+ name: "salt",
21
+ type: "bytes32"
22
+ },
23
+ {
24
+ internalType: "bytes",
25
+ name: "initCode",
26
+ type: "bytes"
27
+ }
28
+ ],
29
+ name: "createAccount",
30
+ outputs: [
31
+ {
32
+ internalType: "address",
33
+ name: "",
34
+ type: "address"
35
+ }
36
+ ],
37
+ stateMutability: "payable",
38
+ type: "function"
39
+ }
40
+ ];
41
+ /**
42
+ * Get default addresses for Etherspot Smart Account based on chainId
43
+ * @param chainId
44
+ * @param validatorAddress
45
+ * @param accountLogicAddress
46
+ * @param factoryAddress
47
+ * @param metaFactoryAddress
48
+ */
49
+ const getDefaultAddresses = ({ validatorAddress: _validatorAddress, metaFactoryAddress: _metaFactoryAddress, bootstrapAddress: _bootstrapAddress }) => {
50
+ const addresses = DEFAULT_CONTRACT_ADDRESS;
51
+ const validatorAddress = _validatorAddress ?? addresses.validatorAddress;
52
+ const metaFactoryAddress = _metaFactoryAddress ?? addresses?.metaFactoryAddress ?? zeroAddress;
53
+ const bootstrapAddress = _bootstrapAddress ?? addresses.bootstrapAddress ?? zeroAddress;
54
+ return {
55
+ validatorAddress,
56
+ metaFactoryAddress,
57
+ bootstrapAddress
58
+ };
59
+ };
60
+ /**
61
+ * Get the initialization data for a etherspot smart account
62
+ * @param entryPoint
63
+ * @param owner
64
+ * @param validatorAddress
65
+ */
66
+ const getInitialisationData = ({ owner, validatorAddress, bootstrapAddress }) => {
67
+ const initMSAData = getInitMSAData(validatorAddress);
68
+ const initCode = encodeAbiParameters([{ type: "address" }, { type: "address" }, { type: "bytes" }], [owner, bootstrapAddress, initMSAData]);
69
+ return initCode;
70
+ };
71
+ /**
72
+ * Get the account initialization code for a etherspot smart account
73
+ * @param entryPoint
74
+ * @param owner
75
+ * @param index
76
+ * @param validatorAddress
77
+ * @param bootstrapAddress
78
+ */
79
+ const getAccountInitCode = async ({ owner, index, validatorAddress, bootstrapAddress }) => {
80
+ if (!owner)
81
+ throw new Error("Owner account not found");
82
+ // Build the account initialization data
83
+ const initialisationData = getInitialisationData({
84
+ validatorAddress,
85
+ owner,
86
+ bootstrapAddress
87
+ });
88
+ return encodeFunctionData({
89
+ abi: createAccountAbi,
90
+ functionName: "createAccount",
91
+ args: [toHex(index, { size: 32 }), initialisationData]
92
+ });
93
+ };
94
+ export async function toEtherspotSmartAccount(parameters) {
95
+ const { client, owners, address, index = BigInt(0), metaFactoryAddress: _metaFactoryAddress, validatorAddress: _validatorAddress, bootstrapAddress: _bootstrapAddress } = parameters;
96
+ const localOwner = await toOwner({ owner: owners[0] });
97
+ const entryPoint = {
98
+ address: parameters.entryPoint?.address ?? entryPoint07Address,
99
+ abi: entryPoint07Abi,
100
+ version: parameters.entryPoint?.version ?? "0.7"
101
+ };
102
+ const { validatorAddress, metaFactoryAddress, bootstrapAddress } = getDefaultAddresses({
103
+ validatorAddress: _validatorAddress,
104
+ metaFactoryAddress: _metaFactoryAddress,
105
+ bootstrapAddress: _bootstrapAddress
106
+ });
107
+ // Helper to generate the init code for the smart account
108
+ const generateInitCode = () => getAccountInitCode({
109
+ owner: localOwner.address,
110
+ index,
111
+ validatorAddress,
112
+ bootstrapAddress
113
+ });
114
+ let accountAddress = address;
115
+ let chainId;
116
+ const getMemoizedChainId = async () => {
117
+ if (chainId)
118
+ return chainId;
119
+ chainId = client.chain
120
+ ? client.chain.id
121
+ : await getAction(client, getChainId, "getChainId")({});
122
+ return chainId;
123
+ };
124
+ const getFactoryArgs = async () => {
125
+ return {
126
+ factory: metaFactoryAddress,
127
+ factoryData: await generateInitCode()
128
+ };
129
+ };
130
+ return toSmartAccount({
131
+ client,
132
+ entryPoint,
133
+ getFactoryArgs,
134
+ async getAddress() {
135
+ if (accountAddress)
136
+ return accountAddress;
137
+ const { factory, factoryData } = await getFactoryArgs();
138
+ // Get the sender address based on the init code
139
+ accountAddress = await getSenderAddress(client, {
140
+ factory,
141
+ factoryData,
142
+ entryPointAddress: entryPoint.address
143
+ });
144
+ return accountAddress;
145
+ },
146
+ async encodeCalls(calls) {
147
+ return encode7579Calls({
148
+ mode: {
149
+ type: calls.length > 1 ? "batchcall" : "call",
150
+ revertOnError: false,
151
+ selector: "0x",
152
+ context: "0x"
153
+ },
154
+ callData: calls
155
+ });
156
+ },
157
+ async getNonce(_args) {
158
+ return getAccountNonce(client, {
159
+ address: await this.getAddress(),
160
+ entryPointAddress: entryPoint.address,
161
+ key: getNonceKeyWithEncoding(validatorAddress,
162
+ /*args?.key ?? */ parameters.nonceKey ?? 0n)
163
+ });
164
+ },
165
+ async getStubSignature() {
166
+ return DUMMY_ECDSA_SIGNATURE;
167
+ },
168
+ async sign({ hash }) {
169
+ return this.signMessage({ message: hash });
170
+ },
171
+ async signMessage({ message }) {
172
+ let signature = await localOwner.signMessage({
173
+ message
174
+ });
175
+ const potentiallyIncorrectV = Number.parseInt(signature.slice(-2), 16);
176
+ if (![27, 28].includes(potentiallyIncorrectV)) {
177
+ const correctV = potentiallyIncorrectV + 27;
178
+ signature = (signature.slice(0, -2) +
179
+ correctV.toString(16));
180
+ }
181
+ return encodePacked(["address", "bytes"], [validatorAddress, signature]);
182
+ },
183
+ async signTypedData(typedData) {
184
+ let signature = await localOwner.signTypedData(typedData);
185
+ const potentiallyIncorrectV = Number.parseInt(signature.slice(-2), 16);
186
+ if (![27, 28].includes(potentiallyIncorrectV)) {
187
+ const correctV = potentiallyIncorrectV + 27;
188
+ signature = (signature.slice(0, -2) +
189
+ correctV.toString(16));
190
+ }
191
+ return encodePacked(["address", "bytes"], [validatorAddress, signature]);
192
+ },
193
+ async signUserOperation(parameters) {
194
+ const { chainId = await getMemoizedChainId(), ...userOperation } = parameters;
195
+ const hash = getUserOperationHash({
196
+ userOperation: {
197
+ ...userOperation,
198
+ sender: userOperation.sender ?? (await this.getAddress()),
199
+ signature: "0x"
200
+ },
201
+ entryPointAddress: entryPoint.address,
202
+ entryPointVersion: entryPoint.version,
203
+ chainId: chainId
204
+ });
205
+ const signature = await localOwner.signMessage({
206
+ message: { raw: hash }
207
+ });
208
+ return signature;
209
+ }
210
+ });
211
+ }
212
+ //# sourceMappingURL=toEtherspotSmartAccount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toEtherspotSmartAccount.js","sourceRoot":"","sources":["../../../accounts/etherspot/toEtherspotSmartAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAYH,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EACZ,KAAK,EACL,WAAW,EACd,MAAM,MAAM,CAAA;AACb,OAAO,EAIH,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACjB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAA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,CAAC;QACD,KAAK,CAAC,iBAAiB,CAAC,UAAU;YAC9B,MAAM,EAAE,OAAO,GAAG,MAAM,kBAAkB,EAAE,EAAE,GAAG,aAAa,EAAE,GAC5D,UAAU,CAAA;YAEd,MAAM,IAAI,GAAG,oBAAoB,CAAC;gBAC9B,aAAa,EAAE;oBACX,GAAG,aAAa;oBAChB,MAAM,EAAE,aAAa,CAAC,MAAM,IAAI,CAAC,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;oBACzD,SAAS,EAAE,IAAI;iBACkB;gBACrC,iBAAiB,EAAE,UAAU,CAAC,OAAO;gBACrC,iBAAiB,EAAE,UAAU,CAAC,OAAO;gBACrC,OAAO,EAAE,OAAO;aACnB,CAAC,CAAA;YAEF,MAAM,SAAS,GAAG,MAAM,UAAU,CAAC,WAAW,CAAC;gBAC3C,OAAO,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;aACzB,CAAC,CAAA;YAEF,OAAO,SAAS,CAAA;QACpB,CAAC;KACJ,CAAkE,CAAA;AACvE,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { encodeFunctionData, zeroAddress } from "viem";
2
+ import { EtherspotBootstrapAbi, EtherspotOnInstallAbi } from "../abi/EtherspotBootstrapAbi.js";
3
+ export const getInitMSAData = (ecdsaValidatorAddress) => {
4
+ const validators = makeBootstrapConfig(ecdsaValidatorAddress, "0x");
5
+ const executors = makeBootstrapConfig(zeroAddress, "0x");
6
+ const hook = _makeBootstrapConfig(zeroAddress, "0x");
7
+ const fallbacks = makeBootstrapConfig(zeroAddress, "0x");
8
+ const initMSAData = encodeFunctionData({
9
+ abi: EtherspotBootstrapAbi,
10
+ functionName: "initMSA",
11
+ args: [validators, executors, hook, fallbacks]
12
+ });
13
+ return initMSAData;
14
+ };
15
+ const _makeBootstrapConfig = (module, data) => {
16
+ const config = {
17
+ module: "",
18
+ data: ""
19
+ };
20
+ config.module = module;
21
+ config.data = encodeFunctionData({
22
+ abi: EtherspotOnInstallAbi,
23
+ functionName: "onInstall",
24
+ args: [data]
25
+ });
26
+ return config;
27
+ };
28
+ const makeBootstrapConfig = (module, data) => {
29
+ const config = [];
30
+ const data1 = encodeFunctionData({
31
+ abi: EtherspotOnInstallAbi,
32
+ functionName: "onInstall",
33
+ args: [data]
34
+ });
35
+ const newConfig = {
36
+ module: module,
37
+ data: data1
38
+ };
39
+ config.push(newConfig);
40
+ return config;
41
+ };
42
+ //# sourceMappingURL=getInitMSAData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getInitMSAData.js","sourceRoot":"","sources":["../../../../accounts/etherspot/utils/getInitMSAData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,kBAAkB,EAAE,WAAW,EAAE,MAAM,MAAM,CAAA;AACpE,OAAO,EACH,qBAAqB,EACrB,qBAAqB,EACxB,MAAM,iCAAiC,CAAA;AAExC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,qBAA8B,EAAE,EAAE;IAC7D,MAAM,UAAU,GAAG,mBAAmB,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAA;IACnE,MAAM,SAAS,GAAG,mBAAmB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA;IACxD,MAAM,IAAI,GAAG,oBAAoB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA;IACpD,MAAM,SAAS,GAAG,mBAAmB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA;IACxD,MAAM,WAAW,GAAG,kBAAkB,CAAC;QACnC,GAAG,EAAE,qBAAqB;QAC1B,YAAY,EAAE,SAAS;QACvB,IAAI,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,CAAC;KACjD,CAAC,CAAA;IAEF,OAAO,WAAW,CAAA;AACtB,CAAC,CAAA;AAED,MAAM,oBAAoB,GAAG,CAAC,MAAc,EAAE,IAAY,EAAE,EAAE;IAC1D,MAAM,MAAM,GAAG;QACX,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,EAAE;KACX,CAAA;IAED,MAAM,CAAC,MAAM,GAAG,MAAM,CAAA;IAEtB,MAAM,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC7B,GAAG,EAAE,qBAAqB;QAC1B,YAAY,EAAE,WAAW;QACzB,IAAI,EAAE,CAAC,IAAqB,CAAC;KAChC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACjB,CAAC,CAAA;AAED,MAAM,mBAAmB,GAAG,CAAC,MAAc,EAAE,IAAY,EAAE,EAAE;IACzD,MAAM,MAAM,GAGN,EAAE,CAAA;IAER,MAAM,KAAK,GAAG,kBAAkB,CAAC;QAC7B,GAAG,EAAE,qBAAqB;QAC1B,YAAY,EAAE,WAAW;QACzB,IAAI,EAAE,CAAC,IAAqB,CAAC;KAChC,CAAC,CAAA;IAEF,MAAM,SAAS,GAAG;QACd,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,KAAK;KACd,CAAA;IACD,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IACtB,OAAO,MAAM,CAAA;AACjB,CAAC,CAAA"}
@@ -0,0 +1,15 @@
1
+ import { concatHex, pad, toHex } from "viem";
2
+ import { VALIDATOR_MODE, VALIDATOR_TYPE } from "../constants.js";
3
+ export const getNonceKeyWithEncoding = (validatorAddress, nonceKey = 0n) => {
4
+ const validatorMode = VALIDATOR_MODE.DEFAULT;
5
+ const validatorType = VALIDATOR_TYPE.ROOT;
6
+ const encoding = pad(concatHex([
7
+ validatorAddress, // 20 bytes
8
+ validatorMode, // 1 byte
9
+ validatorType, // 1 byte
10
+ toHex(nonceKey, { size: 2 }) // 2 byte
11
+ ]), { size: 24 }); // 24 bytes
12
+ const encodedNonceKey = BigInt(encoding);
13
+ return encodedNonceKey;
14
+ };
15
+ //# sourceMappingURL=getNonceKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getNonceKey.js","sourceRoot":"","sources":["../../../../accounts/etherspot/utils/getNonceKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhE,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACnC,gBAAyB,EACzB,QAAQ,GAAG,EAAE,EACf,EAAE;IACA,MAAM,aAAa,GAAG,cAAc,CAAC,OAAO,CAAA;IAC5C,MAAM,aAAa,GAAG,cAAc,CAAC,IAAI,CAAA;IACzC,MAAM,QAAQ,GAAG,GAAG,CAChB,SAAS,CAAC;QACN,gBAAgB,EAAE,WAAW;QAC7B,aAAa,EAAE,SAAS;QACxB,aAAa,EAAE,SAAS;QACxB,KAAK,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,SAAS;KACzC,CAAC,EACF,EAAE,IAAI,EAAE,EAAE,EAAE,CACf,CAAA,CAAC,WAAW;IACb,MAAM,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;IACxC,OAAO,eAAe,CAAA;AAC1B,CAAC,CAAA"}
@@ -0,0 +1,18 @@
1
+ import { concatHex, encodeAbiParameters, keccak256, stringToHex } from "viem";
2
+ import { domainSeparator } from "viem";
3
+ export const wrapMessageHash = (messageHash, { accountAddress, chainId }) => {
4
+ const _domainSeparator = domainSeparator({
5
+ domain: {
6
+ name: "ModularEtherspotWallet",
7
+ chainId,
8
+ verifyingContract: accountAddress
9
+ }
10
+ });
11
+ const wrappedMessageHash = keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }], [
12
+ keccak256(stringToHex("ModularEtherspotWallet(bytes32 hash)")),
13
+ messageHash
14
+ ]));
15
+ const digest = keccak256(concatHex(["0x1901", _domainSeparator, wrappedMessageHash]));
16
+ return digest;
17
+ };
18
+ //# sourceMappingURL=wrapMessageHash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapMessageHash.js","sourceRoot":"","sources":["../../../../accounts/etherspot/utils/wrapMessageHash.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,SAAS,EACT,mBAAmB,EACnB,SAAS,EACT,WAAW,EACd,MAAM,MAAM,CAAA;AACb,OAAO,EAAgB,eAAe,EAAE,MAAM,MAAM,CAAA;AAOpD,MAAM,CAAC,MAAM,eAAe,GAAG,CAC3B,WAAgB,EAChB,EAAE,cAAc,EAAE,OAAO,EAAyB,EACpD,EAAE;IACA,MAAM,gBAAgB,GAAG,eAAe,CAAC;QACrC,MAAM,EAAE;YACJ,IAAI,EAAE,wBAAwB;YAC9B,OAAO;YACP,iBAAiB,EAAE,cAAc;SACpC;KACJ,CAAC,CAAA;IAEF,MAAM,kBAAkB,GAAG,SAAS,CAChC,mBAAmB,CACf,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAC1C;QACI,SAAS,CAAC,WAAW,CAAC,sCAAsC,CAAC,CAAC;QAC9D,WAAW;KACd,CACJ,CACJ,CAAA;IAED,MAAM,MAAM,GAAG,SAAS,CACpB,SAAS,CAAC,CAAC,QAAQ,EAAE,gBAAgB,EAAE,kBAAkB,CAAC,CAAC,CAC9D,CAAA;IAED,OAAO,MAAM,CAAA;AACjB,CAAC,CAAA"}
@@ -1,11 +1,12 @@
1
1
  import { toSimpleSmartAccount } from "./simple/toSimpleSmartAccount.js";
2
2
  import { toLightSmartAccount } from "./light/toLightSmartAccount.js";
3
3
  import { toTrustSmartAccount } from "./trust/toTrustSmartAccount.js";
4
+ import { toEtherspotSmartAccount } from "./etherspot/toEtherspotSmartAccount.js";
4
5
  import { toSafeSmartAccount } from "./safe/toSafeSmartAccount.js";
5
6
  import { toEcdsaKernelSmartAccount } from "./kernel/toEcdsaKernelSmartAccount.js";
6
7
  import { toKernelSmartAccount } from "./kernel/toKernelSmartAccount.js";
7
8
  import { toBiconomySmartAccount } from "./biconomy/toBiconomySmartAccount.js";
8
9
  import { toNexusSmartAccount } from "./nexus/toNexusSmartAccount.js";
9
10
  import { toThirdwebSmartAccount } from "./thirdweb/toThirdwebSmartAccount.js";
10
- export { toSimpleSmartAccount, toLightSmartAccount, toTrustSmartAccount, toSafeSmartAccount, toEcdsaKernelSmartAccount, toKernelSmartAccount, toNexusSmartAccount, toBiconomySmartAccount, toThirdwebSmartAccount };
11
+ export { toSimpleSmartAccount, toLightSmartAccount, toTrustSmartAccount, toSafeSmartAccount, toEcdsaKernelSmartAccount, toKernelSmartAccount, toNexusSmartAccount, toBiconomySmartAccount, toThirdwebSmartAccount, toEtherspotSmartAccount };
11
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../accounts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,oBAAoB,EACvB,MAAM,kCAAkC,CAAA;AAEzC,OAAO,EAKH,mBAAmB,EACtB,MAAM,gCAAgC,CAAA;AAEvC,OAAO,EAIH,mBAAmB,EACtB,MAAM,gCAAgC,CAAA;AAEvC,OAAO,EAKH,kBAAkB,EACrB,MAAM,8BAA8B,CAAA;AAErC,OAAO,EAIH,yBAAyB,EAC5B,MAAM,uCAAuC,CAAA;AAE9C,OAAO,EAKH,oBAAoB,EACvB,MAAM,kCAAkC,CAAA;AAEzC,OAAO,EAIH,sBAAsB,EACzB,MAAM,sCAAsC,CAAA;AAE7C,OAAO,EAIH,mBAAmB,EACtB,MAAM,gCAAgC,CAAA;AAEvC,OAAO,EAIH,sBAAsB,EACzB,MAAM,sCAAsC,CAAA;AAE7C,OAAO,EAIH,oBAAoB,EAKpB,mBAAmB,EAInB,mBAAmB,EAKnB,kBAAkB,EAIlB,yBAAyB,EAKzB,oBAAoB,EAIpB,mBAAmB,EAInB,sBAAsB,EAItB,sBAAsB,EACzB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../accounts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,oBAAoB,EACvB,MAAM,kCAAkC,CAAA;AAEzC,OAAO,EAKH,mBAAmB,EACtB,MAAM,gCAAgC,CAAA;AAEvC,OAAO,EAIH,mBAAmB,EACtB,MAAM,gCAAgC,CAAA;AAEvC,OAAO,EAIH,uBAAuB,EAC1B,MAAM,wCAAwC,CAAA;AAE/C,OAAO,EAKH,kBAAkB,EACrB,MAAM,8BAA8B,CAAA;AAErC,OAAO,EAIH,yBAAyB,EAC5B,MAAM,uCAAuC,CAAA;AAE9C,OAAO,EAKH,oBAAoB,EACvB,MAAM,kCAAkC,CAAA;AAEzC,OAAO,EAIH,sBAAsB,EACzB,MAAM,sCAAsC,CAAA;AAE7C,OAAO,EAIH,mBAAmB,EACtB,MAAM,gCAAgC,CAAA;AAEvC,OAAO,EAIH,sBAAsB,EACzB,MAAM,sCAAsC,CAAA;AAE7C,OAAO,EAIH,oBAAoB,EAKpB,mBAAmB,EAInB,mBAAmB,EAKnB,kBAAkB,EAIlB,yBAAyB,EAKzB,oBAAoB,EAIpB,mBAAmB,EAInB,sBAAsB,EAItB,sBAAsB,EAItB,uBAAuB,EAC1B,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { toSafeSmartAccount } from "./toSafeSmartAccount.js";
2
+ import { signUserOperation } from "./signUserOperation.js";
3
+ const SafeSmartAccount = {
4
+ toSafeSmartAccount,
5
+ signUserOperation
6
+ };
7
+ export { SafeSmartAccount };
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../accounts/safe/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAKH,kBAAkB,EACrB,MAAM,yBAAyB,CAAA;AAEhC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D,MAAM,gBAAgB,GAAG;IACrB,kBAAkB;IAClB,iBAAiB;CACpB,CAAA;AAED,OAAO,EAKH,gBAAgB,EACnB,CAAA"}
@@ -0,0 +1,94 @@
1
+ import { concat, concatHex, decodeAbiParameters, encodeAbiParameters, encodePacked } from "viem";
2
+ import { toOwner } from "../../utils/index.js";
3
+ import { EIP712_SAFE_OPERATION_TYPE_V06, EIP712_SAFE_OPERATION_TYPE_V07, getDefaultAddresses, getPaymasterAndData } from "./toSafeSmartAccount.js";
4
+ export async function signUserOperation(parameters) {
5
+ const { chainId, entryPoint, validAfter = 0, validUntil = 0, safe4337ModuleAddress: _safe4337ModuleAddress, version, owners, signatures: existingSignatures, account, ...userOperation } = parameters;
6
+ const { safe4337ModuleAddress } = getDefaultAddresses(version, entryPoint.version, {
7
+ safe4337ModuleAddress: _safe4337ModuleAddress
8
+ });
9
+ const message = {
10
+ safe: userOperation.sender,
11
+ callData: userOperation.callData,
12
+ nonce: userOperation.nonce,
13
+ initCode: userOperation.initCode ?? "0x",
14
+ maxFeePerGas: userOperation.maxFeePerGas,
15
+ maxPriorityFeePerGas: userOperation.maxPriorityFeePerGas,
16
+ preVerificationGas: userOperation.preVerificationGas,
17
+ verificationGasLimit: userOperation.verificationGasLimit,
18
+ callGasLimit: userOperation.callGasLimit,
19
+ paymasterAndData: userOperation.paymasterAndData ?? "0x",
20
+ validAfter: validAfter,
21
+ validUntil: validUntil,
22
+ entryPoint: entryPoint.address
23
+ };
24
+ if ("initCode" in userOperation) {
25
+ message.paymasterAndData = userOperation.paymasterAndData ?? "0x";
26
+ }
27
+ if ("factory" in userOperation) {
28
+ if (userOperation.factory && userOperation.factoryData) {
29
+ message.initCode = concatHex([
30
+ userOperation.factory,
31
+ userOperation.factoryData
32
+ ]);
33
+ }
34
+ if (!userOperation.sender) {
35
+ throw new Error("Sender is required");
36
+ }
37
+ message.paymasterAndData = getPaymasterAndData({
38
+ ...userOperation,
39
+ sender: userOperation.sender
40
+ });
41
+ }
42
+ const localOwners = [
43
+ await toOwner({
44
+ owner: account
45
+ })
46
+ ];
47
+ let unPackedSignatures = [];
48
+ if (existingSignatures) {
49
+ const decoded = decodeAbiParameters([
50
+ {
51
+ components: [
52
+ { type: "address", name: "signer" },
53
+ { type: "bytes", name: "data" }
54
+ ],
55
+ name: "signatures",
56
+ type: "tuple[]"
57
+ }
58
+ ], existingSignatures);
59
+ unPackedSignatures = decoded[0];
60
+ }
61
+ const signatures = [
62
+ ...unPackedSignatures,
63
+ ...(await Promise.all(localOwners.map(async (localOwner) => ({
64
+ signer: localOwner.address,
65
+ data: await localOwner.signTypedData({
66
+ domain: {
67
+ chainId,
68
+ verifyingContract: safe4337ModuleAddress
69
+ },
70
+ types: entryPoint.version === "0.6"
71
+ ? EIP712_SAFE_OPERATION_TYPE_V06
72
+ : EIP712_SAFE_OPERATION_TYPE_V07,
73
+ primaryType: "SafeOp",
74
+ message: message
75
+ })
76
+ }))))
77
+ ];
78
+ if (signatures.length !== owners.length) {
79
+ return encodeAbiParameters([
80
+ {
81
+ components: [
82
+ { type: "address", name: "signer" },
83
+ { type: "bytes", name: "data" }
84
+ ],
85
+ name: "signatures",
86
+ type: "tuple[]"
87
+ }
88
+ ], [signatures]);
89
+ }
90
+ signatures.sort((left, right) => left.signer.toLowerCase().localeCompare(right.signer.toLowerCase()));
91
+ const signatureBytes = concat(signatures.map((sig) => sig.data));
92
+ return encodePacked(["uint48", "uint48", "bytes"], [validAfter, validUntil, signatureBytes]);
93
+ }
94
+ //# sourceMappingURL=signUserOperation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signUserOperation.js","sourceRoot":"","sources":["../../../accounts/safe/signUserOperation.ts"],"names":[],"mappings":"AAAA,OAAO,EAUH,MAAM,EACN,SAAS,EACT,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACf,MAAM,MAAM,CAAA;AAEb,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAE9C,OAAO,EACH,8BAA8B,EAC9B,8BAA8B,EAE9B,mBAAmB,EACnB,mBAAmB,EACtB,MAAM,yBAAyB,CAAA;AAEhC,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACnC,UAiBC;IAED,MAAM,EACF,OAAO,EACP,UAAU,EACV,UAAU,GAAG,CAAC,EACd,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