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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # permissionless
2
2
 
3
+ ## 0.2.24
4
+
5
+ ### Patch Changes
6
+
7
+ - 30c73e027c5966cb23b3a5d74454d473627098c3: Added support for multi-sig in Safe
8
+
9
+ ## 0.2.23
10
+
11
+ ### Patch Changes
12
+
13
+ - aa7850385a016a1f964639e292f8844929fc16a9: Added support for Etherspot Smart Account
14
+
3
15
  ## 0.2.22
4
16
 
5
17
  ### Patch Changes
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EtherspotOnInstallAbi = exports.EtherspotBootstrapAbi = void 0;
4
+ exports.EtherspotBootstrapAbi = [
5
+ {
6
+ inputs: [
7
+ {
8
+ components: [
9
+ {
10
+ internalType: "address",
11
+ name: "module",
12
+ type: "address"
13
+ },
14
+ {
15
+ internalType: "bytes",
16
+ name: "data",
17
+ type: "bytes"
18
+ }
19
+ ],
20
+ internalType: "struct BootstrapConfig[]",
21
+ name: "$valdiators",
22
+ type: "tuple[]"
23
+ },
24
+ {
25
+ components: [
26
+ {
27
+ internalType: "address",
28
+ name: "module",
29
+ type: "address"
30
+ },
31
+ {
32
+ internalType: "bytes",
33
+ name: "data",
34
+ type: "bytes"
35
+ }
36
+ ],
37
+ internalType: "struct BootstrapConfig[]",
38
+ name: "$executors",
39
+ type: "tuple[]"
40
+ },
41
+ {
42
+ components: [
43
+ {
44
+ internalType: "address",
45
+ name: "module",
46
+ type: "address"
47
+ },
48
+ {
49
+ internalType: "bytes",
50
+ name: "data",
51
+ type: "bytes"
52
+ }
53
+ ],
54
+ internalType: "struct BootstrapConfig",
55
+ name: "_hook",
56
+ type: "tuple"
57
+ },
58
+ {
59
+ components: [
60
+ {
61
+ internalType: "address",
62
+ name: "module",
63
+ type: "address"
64
+ },
65
+ {
66
+ internalType: "bytes",
67
+ name: "data",
68
+ type: "bytes"
69
+ }
70
+ ],
71
+ internalType: "struct BootstrapConfig[]",
72
+ name: "_fallbacks",
73
+ type: "tuple[]"
74
+ }
75
+ ],
76
+ name: "initMSA",
77
+ outputs: [],
78
+ stateMutability: "nonpayable",
79
+ type: "function"
80
+ }
81
+ ];
82
+ exports.EtherspotOnInstallAbi = [
83
+ {
84
+ inputs: [
85
+ {
86
+ internalType: "bytes",
87
+ name: "data",
88
+ type: "bytes"
89
+ }
90
+ ],
91
+ name: "onInstall",
92
+ outputs: [],
93
+ stateMutability: "nonpayable",
94
+ type: "function"
95
+ }
96
+ ];
97
+ //# sourceMappingURL=EtherspotBootstrapAbi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EtherspotBootstrapAbi.js","sourceRoot":"","sources":["../../../../accounts/etherspot/abi/EtherspotBootstrapAbi.ts"],"names":[],"mappings":";;;AAAa,QAAA,qBAAqB,GAAG;IACjC;QACI,MAAM,EAAE;YACJ;gBACI,UAAU,EAAE;oBACR;wBACI,YAAY,EAAE,SAAS;wBACvB,IAAI,EAAE,QAAQ;wBACd,IAAI,EAAE,SAAS;qBAClB;oBACD;wBACI,YAAY,EAAE,OAAO;wBACrB,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,OAAO;qBAChB;iBACJ;gBACD,YAAY,EAAE,0BAA0B;gBACxC,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,SAAS;aAClB;YACD;gBACI,UAAU,EAAE;oBACR;wBACI,YAAY,EAAE,SAAS;wBACvB,IAAI,EAAE,QAAQ;wBACd,IAAI,EAAE,SAAS;qBAClB;oBACD;wBACI,YAAY,EAAE,OAAO;wBACrB,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,OAAO;qBAChB;iBACJ;gBACD,YAAY,EAAE,0BAA0B;gBACxC,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,SAAS;aAClB;YACD;gBACI,UAAU,EAAE;oBACR;wBACI,YAAY,EAAE,SAAS;wBACvB,IAAI,EAAE,QAAQ;wBACd,IAAI,EAAE,SAAS;qBAClB;oBACD;wBACI,YAAY,EAAE,OAAO;wBACrB,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,OAAO;qBAChB;iBACJ;gBACD,YAAY,EAAE,wBAAwB;gBACtC,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,OAAO;aAChB;YACD;gBACI,UAAU,EAAE;oBACR;wBACI,YAAY,EAAE,SAAS;wBACvB,IAAI,EAAE,QAAQ;wBACd,IAAI,EAAE,SAAS;qBAClB;oBACD;wBACI,YAAY,EAAE,OAAO;wBACrB,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,OAAO;qBAChB;iBACJ;gBACD,YAAY,EAAE,0BAA0B;gBACxC,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,SAAS;aAClB;SACJ;QACD,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,EAAE;QACX,eAAe,EAAE,YAAY;QAC7B,IAAI,EAAE,UAAU;KACnB;CACJ,CAAA;AAEY,QAAA,qBAAqB,GAAG;IACjC;QACI,MAAM,EAAE;YACJ;gBACI,YAAY,EAAE,OAAO;gBACrB,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,OAAO;aAChB;SACJ;QACD,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,EAAE;QACX,eAAe,EAAE,YAAY;QAC7B,IAAI,EAAE,UAAU;KACnB;CACK,CAAA"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_CONTRACT_ADDRESS = exports.VALIDATOR_MODE = exports.VALIDATOR_TYPE = exports.DUMMY_ECDSA_SIGNATURE = void 0;
4
+ exports.DUMMY_ECDSA_SIGNATURE = "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";
5
+ exports.VALIDATOR_TYPE = {
6
+ ROOT: "0x00",
7
+ VALIDATOR: "0x01",
8
+ PERMISSION: "0x02"
9
+ };
10
+ var VALIDATOR_MODE;
11
+ (function (VALIDATOR_MODE) {
12
+ VALIDATOR_MODE["DEFAULT"] = "0x00";
13
+ VALIDATOR_MODE["ENABLE"] = "0x01";
14
+ })(VALIDATOR_MODE || (exports.VALIDATOR_MODE = VALIDATOR_MODE = {}));
15
+ exports.DEFAULT_CONTRACT_ADDRESS = {
16
+ metaFactoryAddress: "0x93FB56A4a0B7160fbf8903d251Cc7A3fb9bA0933",
17
+ bootstrapAddress: "0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066",
18
+ validatorAddress: "0x7aCEE15c9FFc1e8f287C26E0f4C8244A0729F557"
19
+ };
20
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../accounts/etherspot/constants.ts"],"names":[],"mappings":";;;AAEa,QAAA,qBAAqB,GAC9B,sIAAsI,CAAA;AAE7H,QAAA,cAAc,GAAG;IAC1B,IAAI,EAAE,MAAM;IACZ,SAAS,EAAE,MAAM;IACjB,UAAU,EAAE,MAAM;CACZ,CAAA;AAEV,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,kCAAgB,CAAA;IAChB,iCAAe,CAAA;AACnB,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAQY,QAAA,wBAAwB,GAAqB;IACtD,kBAAkB,EAAE,4CAA4C;IAChE,gBAAgB,EAAE,4CAA4C;IAC9D,gBAAgB,EAAE,4CAA4C;CACjE,CAAA"}
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toEtherspotSmartAccount = toEtherspotSmartAccount;
4
+ const viem_1 = require("viem");
5
+ const account_abstraction_1 = require("viem/account-abstraction");
6
+ const actions_1 = require("viem/actions");
7
+ const utils_1 = require("viem/utils");
8
+ const getAccountNonce_js_1 = require("../../actions/public/getAccountNonce.js");
9
+ const getSenderAddress_js_1 = require("../../actions/public/getSenderAddress.js");
10
+ const encode7579Calls_js_1 = require("../../utils/encode7579Calls.js");
11
+ const index_js_1 = require("../../utils/index.js");
12
+ const constants_js_1 = require("./constants.js");
13
+ const getInitMSAData_js_1 = require("./utils/getInitMSAData.js");
14
+ const getNonceKey_js_1 = require("./utils/getNonceKey.js");
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
+ const getDefaultAddresses = ({ validatorAddress: _validatorAddress, metaFactoryAddress: _metaFactoryAddress, bootstrapAddress: _bootstrapAddress }) => {
42
+ const addresses = constants_js_1.DEFAULT_CONTRACT_ADDRESS;
43
+ const validatorAddress = _validatorAddress ?? addresses.validatorAddress;
44
+ const metaFactoryAddress = _metaFactoryAddress ?? addresses?.metaFactoryAddress ?? viem_1.zeroAddress;
45
+ const bootstrapAddress = _bootstrapAddress ?? addresses.bootstrapAddress ?? viem_1.zeroAddress;
46
+ return {
47
+ validatorAddress,
48
+ metaFactoryAddress,
49
+ bootstrapAddress
50
+ };
51
+ };
52
+ const getInitialisationData = ({ owner, validatorAddress, bootstrapAddress }) => {
53
+ const initMSAData = (0, getInitMSAData_js_1.getInitMSAData)(validatorAddress);
54
+ const initCode = (0, viem_1.encodeAbiParameters)([{ type: "address" }, { type: "address" }, { type: "bytes" }], [owner, bootstrapAddress, initMSAData]);
55
+ return initCode;
56
+ };
57
+ const getAccountInitCode = async ({ owner, index, validatorAddress, bootstrapAddress }) => {
58
+ if (!owner)
59
+ throw new Error("Owner account not found");
60
+ const initialisationData = getInitialisationData({
61
+ validatorAddress,
62
+ owner,
63
+ bootstrapAddress
64
+ });
65
+ return (0, viem_1.encodeFunctionData)({
66
+ abi: createAccountAbi,
67
+ functionName: "createAccount",
68
+ args: [(0, viem_1.toHex)(index, { size: 32 }), initialisationData]
69
+ });
70
+ };
71
+ async function toEtherspotSmartAccount(parameters) {
72
+ const { client, owners, address, index = BigInt(0), metaFactoryAddress: _metaFactoryAddress, validatorAddress: _validatorAddress, bootstrapAddress: _bootstrapAddress } = parameters;
73
+ const localOwner = await (0, index_js_1.toOwner)({ owner: owners[0] });
74
+ const entryPoint = {
75
+ address: parameters.entryPoint?.address ?? account_abstraction_1.entryPoint07Address,
76
+ abi: account_abstraction_1.entryPoint07Abi,
77
+ version: parameters.entryPoint?.version ?? "0.7"
78
+ };
79
+ const { validatorAddress, metaFactoryAddress, bootstrapAddress } = getDefaultAddresses({
80
+ validatorAddress: _validatorAddress,
81
+ metaFactoryAddress: _metaFactoryAddress,
82
+ bootstrapAddress: _bootstrapAddress
83
+ });
84
+ const generateInitCode = () => getAccountInitCode({
85
+ owner: localOwner.address,
86
+ index,
87
+ validatorAddress,
88
+ bootstrapAddress
89
+ });
90
+ let accountAddress = address;
91
+ let chainId;
92
+ const getMemoizedChainId = async () => {
93
+ if (chainId)
94
+ return chainId;
95
+ chainId = client.chain
96
+ ? client.chain.id
97
+ : await (0, utils_1.getAction)(client, actions_1.getChainId, "getChainId")({});
98
+ return chainId;
99
+ };
100
+ const getFactoryArgs = async () => {
101
+ return {
102
+ factory: metaFactoryAddress,
103
+ factoryData: await generateInitCode()
104
+ };
105
+ };
106
+ return (0, account_abstraction_1.toSmartAccount)({
107
+ client,
108
+ entryPoint,
109
+ getFactoryArgs,
110
+ async getAddress() {
111
+ if (accountAddress)
112
+ return accountAddress;
113
+ const { factory, factoryData } = await getFactoryArgs();
114
+ accountAddress = await (0, getSenderAddress_js_1.getSenderAddress)(client, {
115
+ factory,
116
+ factoryData,
117
+ entryPointAddress: entryPoint.address
118
+ });
119
+ return accountAddress;
120
+ },
121
+ async encodeCalls(calls) {
122
+ return (0, encode7579Calls_js_1.encode7579Calls)({
123
+ mode: {
124
+ type: calls.length > 1 ? "batchcall" : "call",
125
+ revertOnError: false,
126
+ selector: "0x",
127
+ context: "0x"
128
+ },
129
+ callData: calls
130
+ });
131
+ },
132
+ async getNonce(_args) {
133
+ return (0, getAccountNonce_js_1.getAccountNonce)(client, {
134
+ address: await this.getAddress(),
135
+ entryPointAddress: entryPoint.address,
136
+ key: (0, getNonceKey_js_1.getNonceKeyWithEncoding)(validatorAddress, parameters.nonceKey ?? 0n)
137
+ });
138
+ },
139
+ async getStubSignature() {
140
+ return constants_js_1.DUMMY_ECDSA_SIGNATURE;
141
+ },
142
+ async sign({ hash }) {
143
+ return this.signMessage({ message: hash });
144
+ },
145
+ async signMessage({ message }) {
146
+ let signature = await localOwner.signMessage({
147
+ message
148
+ });
149
+ const potentiallyIncorrectV = Number.parseInt(signature.slice(-2), 16);
150
+ if (![27, 28].includes(potentiallyIncorrectV)) {
151
+ const correctV = potentiallyIncorrectV + 27;
152
+ signature = (signature.slice(0, -2) +
153
+ correctV.toString(16));
154
+ }
155
+ return (0, viem_1.encodePacked)(["address", "bytes"], [validatorAddress, signature]);
156
+ },
157
+ async signTypedData(typedData) {
158
+ let signature = await localOwner.signTypedData(typedData);
159
+ const potentiallyIncorrectV = Number.parseInt(signature.slice(-2), 16);
160
+ if (![27, 28].includes(potentiallyIncorrectV)) {
161
+ const correctV = potentiallyIncorrectV + 27;
162
+ signature = (signature.slice(0, -2) +
163
+ correctV.toString(16));
164
+ }
165
+ return (0, viem_1.encodePacked)(["address", "bytes"], [validatorAddress, signature]);
166
+ },
167
+ async signUserOperation(parameters) {
168
+ const { chainId = await getMemoizedChainId(), ...userOperation } = parameters;
169
+ const hash = (0, account_abstraction_1.getUserOperationHash)({
170
+ userOperation: {
171
+ ...userOperation,
172
+ sender: userOperation.sender ?? (await this.getAddress()),
173
+ signature: "0x"
174
+ },
175
+ entryPointAddress: entryPoint.address,
176
+ entryPointVersion: entryPoint.version,
177
+ chainId: chainId
178
+ });
179
+ const signature = await localOwner.signMessage({
180
+ message: { raw: hash }
181
+ });
182
+ return signature;
183
+ }
184
+ });
185
+ }
186
+ //# sourceMappingURL=toEtherspotSmartAccount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toEtherspotSmartAccount.js","sourceRoot":"","sources":["../../../accounts/etherspot/toEtherspotSmartAccount.ts"],"names":[],"mappings":";;AAwMA,0DA+JC;AAvWD,+BAiBa;AACb,kEAQiC;AACjC,0CAAyC;AACzC,sCAAsC;AACtC,gFAAyE;AACzE,kFAA2E;AAC3E,uEAAgE;AAChE,mDAA8C;AAC9C,iDAIuB;AACvB,iEAA0D;AAC1D,2DAAgE;AAKhE,MAAM,gBAAgB,GAAG;IACrB;QACI,MAAM,EAAE;YACJ;gBACI,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,SAAS;aAClB;YACD;gBACI,YAAY,EAAE,OAAO;gBACrB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,OAAO;aAChB;SACJ;QACD,IAAI,EAAE,eAAe;QACrB,OAAO,EAAE;YACL;gBACI,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,SAAS;aAClB;SACJ;QACD,eAAe,EAAE,SAAS;QAC1B,IAAI,EAAE,UAAU;KACnB;CACK,CAAA;AAUV,MAAM,mBAAmB,GAAG,CAAC,EACzB,gBAAgB,EAAE,iBAAiB,EACnC,kBAAkB,EAAE,mBAAmB,EACvC,gBAAgB,EAAE,iBAAiB,EACX,EAAoB,EAAE;IAC9C,MAAM,SAAS,GAAG,uCAAwB,CAAA;IAC1C,MAAM,gBAAgB,GAAG,iB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CAAC,CAAC;oBAC/B,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAQ,CAAA;YACrC,CAAC;YAED,OAAO,IAAA,mBAAY,EACf,CAAC,SAAS,EAAE,OAAO,CAAC,EACpB,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAChC,CAAA;QACL,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,IAAA,0CAAoB,EAAC;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,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getInitMSAData = void 0;
4
+ const viem_1 = require("viem");
5
+ const EtherspotBootstrapAbi_js_1 = require("../abi/EtherspotBootstrapAbi.js");
6
+ const getInitMSAData = (ecdsaValidatorAddress) => {
7
+ const validators = makeBootstrapConfig(ecdsaValidatorAddress, "0x");
8
+ const executors = makeBootstrapConfig(viem_1.zeroAddress, "0x");
9
+ const hook = _makeBootstrapConfig(viem_1.zeroAddress, "0x");
10
+ const fallbacks = makeBootstrapConfig(viem_1.zeroAddress, "0x");
11
+ const initMSAData = (0, viem_1.encodeFunctionData)({
12
+ abi: EtherspotBootstrapAbi_js_1.EtherspotBootstrapAbi,
13
+ functionName: "initMSA",
14
+ args: [validators, executors, hook, fallbacks]
15
+ });
16
+ return initMSAData;
17
+ };
18
+ exports.getInitMSAData = getInitMSAData;
19
+ const _makeBootstrapConfig = (module, data) => {
20
+ const config = {
21
+ module: "",
22
+ data: ""
23
+ };
24
+ config.module = module;
25
+ config.data = (0, viem_1.encodeFunctionData)({
26
+ abi: EtherspotBootstrapAbi_js_1.EtherspotOnInstallAbi,
27
+ functionName: "onInstall",
28
+ args: [data]
29
+ });
30
+ return config;
31
+ };
32
+ const makeBootstrapConfig = (module, data) => {
33
+ const config = [];
34
+ const data1 = (0, viem_1.encodeFunctionData)({
35
+ abi: EtherspotBootstrapAbi_js_1.EtherspotOnInstallAbi,
36
+ functionName: "onInstall",
37
+ args: [data]
38
+ });
39
+ const newConfig = {
40
+ module: module,
41
+ data: data1
42
+ };
43
+ config.push(newConfig);
44
+ return config;
45
+ };
46
+ //# sourceMappingURL=getInitMSAData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getInitMSAData.js","sourceRoot":"","sources":["../../../../accounts/etherspot/utils/getInitMSAData.ts"],"names":[],"mappings":";;;AAAA,+BAAoE;AACpE,8EAGwC;AAEjC,MAAM,cAAc,GAAG,CAAC,qBAA8B,EAAE,EAAE;IAC7D,MAAM,UAAU,GAAG,mBAAmB,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAA;IACnE,MAAM,SAAS,GAAG,mBAAmB,CAAC,kBAAW,EAAE,IAAI,CAAC,CAAA;IACxD,MAAM,IAAI,GAAG,oBAAoB,CAAC,kBAAW,EAAE,IAAI,CAAC,CAAA;IACpD,MAAM,SAAS,GAAG,mBAAmB,CAAC,kBAAW,EAAE,IAAI,CAAC,CAAA;IACxD,MAAM,WAAW,GAAG,IAAA,yBAAkB,EAAC;QACnC,GAAG,EAAE,gDAAqB;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;AAZY,QAAA,cAAc,kBAY1B;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,IAAA,yBAAkB,EAAC;QAC7B,GAAG,EAAE,gDAAqB;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,IAAA,yBAAkB,EAAC;QAC7B,GAAG,EAAE,gDAAqB;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,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNonceKeyWithEncoding = void 0;
4
+ const viem_1 = require("viem");
5
+ const constants_js_1 = require("../constants.js");
6
+ const getNonceKeyWithEncoding = (validatorAddress, nonceKey = 0n) => {
7
+ const validatorMode = constants_js_1.VALIDATOR_MODE.DEFAULT;
8
+ const validatorType = constants_js_1.VALIDATOR_TYPE.ROOT;
9
+ const encoding = (0, viem_1.pad)((0, viem_1.concatHex)([
10
+ validatorAddress,
11
+ validatorMode,
12
+ validatorType,
13
+ (0, viem_1.toHex)(nonceKey, { size: 2 })
14
+ ]), { size: 24 });
15
+ const encodedNonceKey = BigInt(encoding);
16
+ return encodedNonceKey;
17
+ };
18
+ exports.getNonceKeyWithEncoding = getNonceKeyWithEncoding;
19
+ //# sourceMappingURL=getNonceKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getNonceKey.js","sourceRoot":"","sources":["../../../../accounts/etherspot/utils/getNonceKey.ts"],"names":[],"mappings":";;;AAAA,+BAA0D;AAC1D,kDAAgE;AAEzD,MAAM,uBAAuB,GAAG,CACnC,gBAAyB,EACzB,QAAQ,GAAG,EAAE,EACf,EAAE;IACA,MAAM,aAAa,GAAG,6BAAc,CAAC,OAAO,CAAA;IAC5C,MAAM,aAAa,GAAG,6BAAc,CAAC,IAAI,CAAA;IACzC,MAAM,QAAQ,GAAG,IAAA,UAAG,EAChB,IAAA,gBAAS,EAAC;QACN,gBAAgB;QAChB,aAAa;QACb,aAAa;QACb,IAAA,YAAK,EAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;KAC/B,CAAC,EACF,EAAE,IAAI,EAAE,EAAE,EAAE,CACf,CAAA;IACD,MAAM,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;IACxC,OAAO,eAAe,CAAA;AAC1B,CAAC,CAAA;AAjBY,QAAA,uBAAuB,2BAiBnC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.wrapMessageHash = void 0;
4
+ const viem_1 = require("viem");
5
+ const viem_2 = require("viem");
6
+ const wrapMessageHash = (messageHash, { accountAddress, chainId }) => {
7
+ const _domainSeparator = (0, viem_2.domainSeparator)({
8
+ domain: {
9
+ name: "ModularEtherspotWallet",
10
+ chainId,
11
+ verifyingContract: accountAddress
12
+ }
13
+ });
14
+ const wrappedMessageHash = (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "bytes32" }, { type: "bytes32" }], [
15
+ (0, viem_1.keccak256)((0, viem_1.stringToHex)("ModularEtherspotWallet(bytes32 hash)")),
16
+ messageHash
17
+ ]));
18
+ const digest = (0, viem_1.keccak256)((0, viem_1.concatHex)(["0x1901", _domainSeparator, wrappedMessageHash]));
19
+ return digest;
20
+ };
21
+ exports.wrapMessageHash = wrapMessageHash;
22
+ //# sourceMappingURL=wrapMessageHash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapMessageHash.js","sourceRoot":"","sources":["../../../../accounts/etherspot/utils/wrapMessageHash.ts"],"names":[],"mappings":";;;AAAA,+BAMa;AACb,+BAAoD;AAO7C,MAAM,eAAe,GAAG,CAC3B,WAAgB,EAChB,EAAE,cAAc,EAAE,OAAO,EAAyB,EACpD,EAAE;IACA,MAAM,gBAAgB,GAAG,IAAA,sBAAe,EAAC;QACrC,MAAM,EAAE;YACJ,IAAI,EAAE,wBAAwB;YAC9B,OAAO;YACP,iBAAiB,EAAE,cAAc;SACpC;KACJ,CAAC,CAAA;IAEF,MAAM,kBAAkB,GAAG,IAAA,gBAAS,EAChC,IAAA,0BAAmB,EACf,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAC1C;QACI,IAAA,gBAAS,EAAC,IAAA,kBAAW,EAAC,sCAAsC,CAAC,CAAC;QAC9D,WAAW;KACd,CACJ,CACJ,CAAA;IAED,MAAM,MAAM,GAAG,IAAA,gBAAS,EACpB,IAAA,gBAAS,EAAC,CAAC,QAAQ,EAAE,gBAAgB,EAAE,kBAAkB,CAAC,CAAC,CAC9D,CAAA;IAED,OAAO,MAAM,CAAA;AACjB,CAAC,CAAA;AA3BY,QAAA,eAAe,mBA2B3B"}
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toThirdwebSmartAccount = exports.toBiconomySmartAccount = exports.toNexusSmartAccount = exports.toKernelSmartAccount = exports.toEcdsaKernelSmartAccount = exports.toSafeSmartAccount = exports.toTrustSmartAccount = exports.toLightSmartAccount = exports.toSimpleSmartAccount = void 0;
3
+ exports.toEtherspotSmartAccount = exports.toThirdwebSmartAccount = exports.toBiconomySmartAccount = exports.toNexusSmartAccount = exports.toKernelSmartAccount = exports.toEcdsaKernelSmartAccount = exports.toSafeSmartAccount = exports.toTrustSmartAccount = exports.toLightSmartAccount = exports.toSimpleSmartAccount = void 0;
4
4
  const toSimpleSmartAccount_js_1 = require("./simple/toSimpleSmartAccount.js");
5
5
  Object.defineProperty(exports, "toSimpleSmartAccount", { enumerable: true, get: function () { return toSimpleSmartAccount_js_1.toSimpleSmartAccount; } });
6
6
  const toLightSmartAccount_js_1 = require("./light/toLightSmartAccount.js");
7
7
  Object.defineProperty(exports, "toLightSmartAccount", { enumerable: true, get: function () { return toLightSmartAccount_js_1.toLightSmartAccount; } });
8
8
  const toTrustSmartAccount_js_1 = require("./trust/toTrustSmartAccount.js");
9
9
  Object.defineProperty(exports, "toTrustSmartAccount", { enumerable: true, get: function () { return toTrustSmartAccount_js_1.toTrustSmartAccount; } });
10
+ const toEtherspotSmartAccount_js_1 = require("./etherspot/toEtherspotSmartAccount.js");
11
+ Object.defineProperty(exports, "toEtherspotSmartAccount", { enumerable: true, get: function () { return toEtherspotSmartAccount_js_1.toEtherspotSmartAccount; } });
10
12
  const toSafeSmartAccount_js_1 = require("./safe/toSafeSmartAccount.js");
11
13
  Object.defineProperty(exports, "toSafeSmartAccount", { enumerable: true, get: function () { return toSafeSmartAccount_js_1.toSafeSmartAccount; } });
12
14
  const toEcdsaKernelSmartAccount_js_1 = require("./kernel/toEcdsaKernelSmartAccount.js");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../accounts/index.ts"],"names":[],"mappings":";;;AAAA,8EAKyC;AAiErC,qGAlEA,8CAAoB,OAkEA;AA/DxB,2EAMuC;AA8DnC,oGA/DA,4CAAmB,OA+DA;AA5DvB,2EAKuC;AA2DnC,oGA5DA,4CAAmB,OA4DA;AAzDvB,wEAMqC;AAwDjC,mGAzDA,0CAAkB,OAyDA;AAtDtB,wFAK8C;AAqD1C,0GAtDA,wDAAyB,OAsDA;AAnD7B,8EAMyC;AAkDrC,qGAnDA,8CAAoB,OAmDA;AAhDxB,oFAK6C;AAmDzC,uGApDA,kDAAsB,OAoDA;AAjD1B,2EAKuC;AAwCnC,oGAzCA,4CAAmB,OAyCA;AAtCvB,oFAK6C;AAyCzC,uGA1CA,kDAAsB,OA0CA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../accounts/index.ts"],"names":[],"mappings":";;;AAAA,8EAKyC;AAwErC,qGAzEA,8CAAoB,OAyEA;AAtExB,2EAMuC;AAqEnC,oGAtEA,4CAAmB,OAsEA;AAnEvB,2EAKuC;AAkEnC,oGAnEA,4CAAmB,OAmEA;AAhEvB,uFAK+C;AAyF3C,wGA1FA,oDAAuB,OA0FA;AAvF3B,wEAMqC;AAwDjC,mGAzDA,0CAAkB,OAyDA;AAtDtB,wFAK8C;AAqD1C,0GAtDA,wDAAyB,OAsDA;AAnD7B,8EAMyC;AAkDrC,qGAnDA,8CAAoB,OAmDA;AAhDxB,oFAK6C;AAmDzC,uGApDA,kDAAsB,OAoDA;AAjD1B,2EAKuC;AAwCnC,oGAzCA,4CAAmB,OAyCA;AAtCvB,oFAK6C;AAyCzC,uGA1CA,kDAAsB,OA0CA"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SafeSmartAccount = void 0;
4
+ const toSafeSmartAccount_js_1 = require("./toSafeSmartAccount.js");
5
+ const signUserOperation_js_1 = require("./signUserOperation.js");
6
+ const SafeSmartAccount = {
7
+ toSafeSmartAccount: toSafeSmartAccount_js_1.toSafeSmartAccount,
8
+ signUserOperation: signUserOperation_js_1.signUserOperation
9
+ };
10
+ exports.SafeSmartAccount = SafeSmartAccount;
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../accounts/safe/index.ts"],"names":[],"mappings":";;;AAAA,mEAMgC;AAEhC,iEAA0D;AAE1D,MAAM,gBAAgB,GAAG;IACrB,kBAAkB,EAAlB,0CAAkB;IAClB,iBAAiB,EAAjB,wCAAiB;CACpB,CAAA;AAOG,4CAAgB"}
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.signUserOperation = signUserOperation;
4
+ const viem_1 = require("viem");
5
+ const index_js_1 = require("../../utils/index.js");
6
+ const toSafeSmartAccount_js_1 = require("./toSafeSmartAccount.js");
7
+ async function signUserOperation(parameters) {
8
+ const { chainId, entryPoint, validAfter = 0, validUntil = 0, safe4337ModuleAddress: _safe4337ModuleAddress, version, owners, signatures: existingSignatures, account, ...userOperation } = parameters;
9
+ const { safe4337ModuleAddress } = (0, toSafeSmartAccount_js_1.getDefaultAddresses)(version, entryPoint.version, {
10
+ safe4337ModuleAddress: _safe4337ModuleAddress
11
+ });
12
+ const message = {
13
+ safe: userOperation.sender,
14
+ callData: userOperation.callData,
15
+ nonce: userOperation.nonce,
16
+ initCode: userOperation.initCode ?? "0x",
17
+ maxFeePerGas: userOperation.maxFeePerGas,
18
+ maxPriorityFeePerGas: userOperation.maxPriorityFeePerGas,
19
+ preVerificationGas: userOperation.preVerificationGas,
20
+ verificationGasLimit: userOperation.verificationGasLimit,
21
+ callGasLimit: userOperation.callGasLimit,
22
+ paymasterAndData: userOperation.paymasterAndData ?? "0x",
23
+ validAfter: validAfter,
24
+ validUntil: validUntil,
25
+ entryPoint: entryPoint.address
26
+ };
27
+ if ("initCode" in userOperation) {
28
+ message.paymasterAndData = userOperation.paymasterAndData ?? "0x";
29
+ }
30
+ if ("factory" in userOperation) {
31
+ if (userOperation.factory && userOperation.factoryData) {
32
+ message.initCode = (0, viem_1.concatHex)([
33
+ userOperation.factory,
34
+ userOperation.factoryData
35
+ ]);
36
+ }
37
+ if (!userOperation.sender) {
38
+ throw new Error("Sender is required");
39
+ }
40
+ message.paymasterAndData = (0, toSafeSmartAccount_js_1.getPaymasterAndData)({
41
+ ...userOperation,
42
+ sender: userOperation.sender
43
+ });
44
+ }
45
+ const localOwners = [
46
+ await (0, index_js_1.toOwner)({
47
+ owner: account
48
+ })
49
+ ];
50
+ let unPackedSignatures = [];
51
+ if (existingSignatures) {
52
+ const decoded = (0, viem_1.decodeAbiParameters)([
53
+ {
54
+ components: [
55
+ { type: "address", name: "signer" },
56
+ { type: "bytes", name: "data" }
57
+ ],
58
+ name: "signatures",
59
+ type: "tuple[]"
60
+ }
61
+ ], existingSignatures);
62
+ unPackedSignatures = decoded[0];
63
+ }
64
+ const signatures = [
65
+ ...unPackedSignatures,
66
+ ...(await Promise.all(localOwners.map(async (localOwner) => ({
67
+ signer: localOwner.address,
68
+ data: await localOwner.signTypedData({
69
+ domain: {
70
+ chainId,
71
+ verifyingContract: safe4337ModuleAddress
72
+ },
73
+ types: entryPoint.version === "0.6"
74
+ ? toSafeSmartAccount_js_1.EIP712_SAFE_OPERATION_TYPE_V06
75
+ : toSafeSmartAccount_js_1.EIP712_SAFE_OPERATION_TYPE_V07,
76
+ primaryType: "SafeOp",
77
+ message: message
78
+ })
79
+ }))))
80
+ ];
81
+ if (signatures.length !== owners.length) {
82
+ return (0, viem_1.encodeAbiParameters)([
83
+ {
84
+ components: [
85
+ { type: "address", name: "signer" },
86
+ { type: "bytes", name: "data" }
87
+ ],
88
+ name: "signatures",
89
+ type: "tuple[]"
90
+ }
91
+ ], [signatures]);
92
+ }
93
+ signatures.sort((left, right) => left.signer.toLowerCase().localeCompare(right.signer.toLowerCase()));
94
+ const signatureBytes = (0, viem_1.concat)(signatures.map((sig) => sig.data));
95
+ return (0, viem_1.encodePacked)(["uint48", "uint48", "bytes"], [validAfter, validUntil, signatureBytes]);
96
+ }
97
+ //# sourceMappingURL=signUserOperation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signUserOperation.js","sourceRoot":"","sources":["../../../accounts/safe/signUserOperation.ts"],"names":[],"mappings":";;AA2BA,8CAqJC;AAhLD,+BAea;AAEb,mDAA8C;AAE9C,mEAMgC;AAEzB,KAAK,UAAU,iBAAiB,CACnC,UAiBC;IAED,MAAM,EACF,OAAO,EACP,UAAU,EACV,UAAU,GAAG,CAAC,EACd,UAAU,GAAG,CAAC,EACd,qBAAqB,EAAE,sBAAsB,EAC7C,OAAO,EACP,MAAM,EACN,UAAU,EAAE,kBAAkB,EAC9B,OAAO,EACP,GAAG,aAAa,EACnB,GAAG,UAAU,CAAA;IAEd,MAAM,EAAE,qBAAqB,EAAE,GAAG,IAAA,2CAAmB,EACjD,OAAO,EACP,UAAU,CAAC,OAAO,EAClB;QACI,qBAAqB,EAAE,sBAAsB;KAChD,CACJ,CAAA;IAED,MAAM,OAAO,GAAG;QACZ,IAAI,EAAE,aAAa,CAAC,MAAM;QAC1B,QAAQ,EAAE,aAAa,CAAC,QAAQ;QAChC,KAAK,EAAE,aAAa,CAAC,KAAK;QAC1B,QAAQ,EAAE,aAAa,CAAC,QAAQ,IAAI,IAAI;QACxC,YAAY,EAAE,aAAa,CAAC,YAAY;QACxC,oBAAoB,EAAE,aAAa,CAAC,oBAAoB;QACxD,kBAAkB,EAAE,aAAa,CAAC,kBAAkB;QACpD,oBAAoB,EAAE,aAAa,CAAC,oBAAoB;QACxD,YAAY,EAAE,aAAa,CAAC,YAAY;QACxC,gBAAgB,EAAE,aAAa,CAAC,gBAAgB,IAAI,IAAI;QACxD,UAAU,EAAE,UAAU;QACtB,UAAU,EAAE,UAAU;QACtB,UAAU,EAAE,UAAU,CAAC,OAAO;KACjC,CAAA;IAED,IAAI,UAAU,IAAI,aAAa,EAAE,CAAC;QAC9B,OAAO,CAAC,gBAAgB,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