permissionless 0.1.22 → 0.1.23

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # permissionless
2
2
 
3
+ ## 0.1.23
4
+
5
+ ### Patch Changes
6
+
7
+ - 976884bf550c0ee355974bb8e85a2feb6aa2aaa2: Added Alchemy's LightAccount support v1.1.0
8
+
3
9
  ## 0.1.22
4
10
 
5
11
  ### Patch Changes
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toSmartAccount = exports.signerToBiconomySmartAccount = exports.signerToEcdsaKernelSmartAccount = exports.privateKeyToSafeSmartAccount = exports.privateKeyToSimpleSmartAccount = exports.privateKeyToBiconomySmartAccount = exports.SignTransactionNotSupportedBySmartAccount = exports.signerToSimpleSmartAccount = exports.signerToSafeSmartAccount = void 0;
3
+ exports.toSmartAccount = exports.signerToBiconomySmartAccount = exports.signerToEcdsaKernelSmartAccount = exports.privateKeyToSafeSmartAccount = exports.privateKeyToLightSmartAccount = exports.privateKeyToSimpleSmartAccount = exports.privateKeyToBiconomySmartAccount = exports.SignTransactionNotSupportedBySmartAccount = exports.signerToLightSmartAccount = exports.signerToSimpleSmartAccount = exports.signerToSafeSmartAccount = void 0;
4
4
  const privateKeyToSimpleSmartAccount_1 = require("./simple/privateKeyToSimpleSmartAccount.js");
5
5
  Object.defineProperty(exports, "privateKeyToSimpleSmartAccount", { enumerable: true, get: function () { return privateKeyToSimpleSmartAccount_1.privateKeyToSimpleSmartAccount; } });
6
6
  const signerToSimpleSmartAccount_1 = require("./simple/signerToSimpleSmartAccount.js");
7
7
  Object.defineProperty(exports, "signerToSimpleSmartAccount", { enumerable: true, get: function () { return signerToSimpleSmartAccount_1.signerToSimpleSmartAccount; } });
8
+ const privateKeyToLightSmartAccount_1 = require("./light/privateKeyToLightSmartAccount.js");
9
+ Object.defineProperty(exports, "privateKeyToLightSmartAccount", { enumerable: true, get: function () { return privateKeyToLightSmartAccount_1.privateKeyToLightSmartAccount; } });
10
+ const signerToLightSmartAccount_1 = require("./light/signerToLightSmartAccount.js");
11
+ Object.defineProperty(exports, "signerToLightSmartAccount", { enumerable: true, get: function () { return signerToLightSmartAccount_1.signerToLightSmartAccount; } });
8
12
  const privateKeyToSafeSmartAccount_1 = require("./safe/privateKeyToSafeSmartAccount.js");
9
13
  Object.defineProperty(exports, "privateKeyToSafeSmartAccount", { enumerable: true, get: function () { return privateKeyToSafeSmartAccount_1.privateKeyToSafeSmartAccount; } });
10
14
  const signerToSafeSmartAccount_1 = require("./safe/signerToSafeSmartAccount.js");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../accounts/index.ts"],"names":[],"mappings":";;;AAAA,4FAGgD;AAsD5C,+GAvDA,+DAA8B,OAuDA;AApDlC,oFAI4C;AA6CxC,2GA9CA,uDAA0B,OA8CA;AA3C9B,sFAG4C;AA6CxC,6GA9CA,2DAA4B,OA8CA;AA3ChC,8EAKwC;AA+BpC,yGAhCA,mDAAwB,OAgCA;AA7B5B,8FAIiD;AAkC7C,gHAnCA,iEAA+B,OAmCA;AAhCnC,0FAIgD;AA8B5C,6GA/BA,2DAA4B,OA+BA;AA5BhC,kGAGoD;AAkBhD,iHAnBA,mEAAgC,OAmBA;AAhBpC,mCAIgB;AAWZ,0HAdA,iDAAyC,OAcA;AAT7C,qDAAiD;AAkB7C,+FAlBK,+BAAc,OAkBL"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../accounts/index.ts"],"names":[],"mappings":";;;AAAA,4FAGgD;AAmE5C,+GApEA,+DAA8B,OAoEA;AAjElC,oFAI4C;AAwDxC,2GAzDA,uDAA0B,OAyDA;AAtD9B,yFAG8C;AAyD1C,8GA1DA,6DAA6B,OA0DA;AAvDjC,iFAI0C;AA+CtC,0GAhDA,qDAAyB,OAgDA;AA7C7B,sFAG4C;AAgDxC,6GAjDA,2DAA4B,OAiDA;AA9ChC,8EAKwC;AA+BpC,yGAhCA,mDAAwB,OAgCA;AA7B5B,8FAIiD;AAqC7C,gHAtCA,iEAA+B,OAsCA;AAnCnC,0FAIgD;AAiC5C,6GAlCA,2DAA4B,OAkCA;AA/BhC,kGAGoD;AAoBhD,iHArBA,mEAAgC,OAqBA;AAlBpC,mCAIgB;AAaZ,0HAhBA,iDAAyC,OAgBA;AAX7C,qDAAiD;AAqB7C,+FArBK,+BAAc,OAqBL"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.privateKeyToLightSmartAccount = void 0;
4
+ const accounts_1 = require("viem/accounts");
5
+ const signerToLightSmartAccount_1 = require("./signerToLightSmartAccount.js");
6
+ async function privateKeyToLightSmartAccount(client, { privateKey, ...rest }) {
7
+ const privateKeyAccount = (0, accounts_1.privateKeyToAccount)(privateKey);
8
+ return (0, signerToLightSmartAccount_1.signerToLightSmartAccount)(client, {
9
+ signer: privateKeyAccount,
10
+ ...rest
11
+ });
12
+ }
13
+ exports.privateKeyToLightSmartAccount = privateKeyToLightSmartAccount;
14
+ //# sourceMappingURL=privateKeyToLightSmartAccount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"privateKeyToLightSmartAccount.js","sourceRoot":"","sources":["../../../accounts/light/privateKeyToLightSmartAccount.ts"],"names":[],"mappings":";;;AACA,4CAAmD;AAEnD,2EAIoC;AAe7B,KAAK,UAAU,6BAA6B,CAK/C,MAA6C,EAC7C,EAAE,UAAU,EAAE,GAAG,IAAI,EAAuD;IAE5E,MAAM,iBAAiB,GAAG,IAAA,8BAAmB,EAAC,UAAU,CAAC,CAAA;IAEzD,OAAO,IAAA,qDAAyB,EAAC,MAAM,EAAE;QACrC,MAAM,EAAE,iBAAiB;QACzB,GAAG,IAAI;KACV,CAAC,CAAA;AACN,CAAC;AAdD,sEAcC"}
@@ -0,0 +1,255 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.signerToLightSmartAccount = void 0;
4
+ const viem_1 = require("viem");
5
+ const actions_1 = require("viem/actions");
6
+ const getAccountNonce_1 = require("../../actions/public/getAccountNonce.js");
7
+ const getSenderAddress_1 = require("../../actions/public/getSenderAddress.js");
8
+ const utils_1 = require("../../utils/index.js");
9
+ const getUserOperationHash_1 = require("../../utils/getUserOperationHash.js");
10
+ const isSmartAccountDeployed_1 = require("../../utils/isSmartAccountDeployed.js");
11
+ const toSmartAccount_1 = require("../toSmartAccount.js");
12
+ const types_1 = require("../types.js");
13
+ const getAccountInitCode = async (owner, index = BigInt(0)) => {
14
+ if (!owner)
15
+ throw new Error("Owner account not found");
16
+ return (0, viem_1.encodeFunctionData)({
17
+ abi: [
18
+ {
19
+ inputs: [
20
+ {
21
+ internalType: "address",
22
+ name: "owner",
23
+ type: "address"
24
+ },
25
+ {
26
+ internalType: "uint256",
27
+ name: "salt",
28
+ type: "uint256"
29
+ }
30
+ ],
31
+ name: "createAccount",
32
+ outputs: [
33
+ {
34
+ internalType: "contract LightAccount",
35
+ name: "ret",
36
+ type: "address"
37
+ }
38
+ ],
39
+ stateMutability: "nonpayable",
40
+ type: "function"
41
+ }
42
+ ],
43
+ functionName: "createAccount",
44
+ args: [owner, index]
45
+ });
46
+ };
47
+ const getAccountAddress = async ({ client, factoryAddress, entryPoint: entryPointAddress, owner, index = BigInt(0) }) => {
48
+ const entryPointVersion = (0, utils_1.getEntryPointVersion)(entryPointAddress);
49
+ const factoryData = await getAccountInitCode(owner, index);
50
+ if (entryPointVersion === "v0.6") {
51
+ return (0, getSenderAddress_1.getSenderAddress)(client, {
52
+ initCode: (0, viem_1.concatHex)([factoryAddress, factoryData]),
53
+ entryPoint: entryPointAddress
54
+ });
55
+ }
56
+ return (0, getSenderAddress_1.getSenderAddress)(client, {
57
+ factory: factoryAddress,
58
+ factoryData,
59
+ entryPoint: entryPointAddress
60
+ });
61
+ };
62
+ async function signWith1271WrapperV1(signer, chainId, accountAddress, hashedMessage) {
63
+ return signer.signTypedData({
64
+ domain: {
65
+ chainId: Number(chainId),
66
+ name: "LightAccount",
67
+ verifyingContract: accountAddress,
68
+ version: "1"
69
+ },
70
+ types: {
71
+ LightAccountMessage: [{ name: "message", type: "bytes" }]
72
+ },
73
+ message: {
74
+ message: hashedMessage
75
+ },
76
+ primaryType: "LightAccountMessage"
77
+ });
78
+ }
79
+ const LIGHT_VERSION_TO_ADDRESSES_MAP = {
80
+ "v1.1.0": {
81
+ factoryAddress: "0x00004EC70002a32400f8ae005A26081065620D20"
82
+ }
83
+ };
84
+ const getDefaultAddresses = (lightVersion, { factoryAddress: _factoryAddress }) => {
85
+ const factoryAddress = _factoryAddress ??
86
+ LIGHT_VERSION_TO_ADDRESSES_MAP[lightVersion].factoryAddress;
87
+ return {
88
+ factoryAddress
89
+ };
90
+ };
91
+ async function signerToLightSmartAccount(client, { signer, address, lightVersion, entryPoint: entryPointAddress, index = BigInt(0), factoryAddress: _factoryAddress }) {
92
+ const viemSigner = {
93
+ ...signer,
94
+ signTransaction: (_, __) => {
95
+ throw new types_1.SignTransactionNotSupportedBySmartAccount();
96
+ }
97
+ };
98
+ if (lightVersion !== "v1.1.0") {
99
+ throw new Error("Only Light Account version v1.1.0 is supported at the moment");
100
+ }
101
+ const { factoryAddress } = getDefaultAddresses(lightVersion, {
102
+ factoryAddress: _factoryAddress
103
+ });
104
+ const [accountAddress, chainId] = await Promise.all([
105
+ address ??
106
+ getAccountAddress({
107
+ client,
108
+ factoryAddress,
109
+ entryPoint: entryPointAddress,
110
+ owner: viemSigner.address,
111
+ index
112
+ }),
113
+ client.chain?.id ?? (0, actions_1.getChainId)(client)
114
+ ]);
115
+ if (!accountAddress)
116
+ throw new Error("Account address not found");
117
+ let smartAccountDeployed = await (0, isSmartAccountDeployed_1.isSmartAccountDeployed)(client, accountAddress);
118
+ return (0, toSmartAccount_1.toSmartAccount)({
119
+ address: accountAddress,
120
+ signMessage: async ({ message }) => {
121
+ return signWith1271WrapperV1(signer, chainId, accountAddress, (0, viem_1.hashMessage)(message));
122
+ },
123
+ signTransaction: (_, __) => {
124
+ throw new types_1.SignTransactionNotSupportedBySmartAccount();
125
+ },
126
+ async signTypedData(typedData) {
127
+ return signWith1271WrapperV1(signer, chainId, accountAddress, (0, viem_1.hashTypedData)(typedData));
128
+ },
129
+ client: client,
130
+ publicKey: accountAddress,
131
+ entryPoint: entryPointAddress,
132
+ source: "LightSmartAccount",
133
+ async getNonce() {
134
+ return (0, getAccountNonce_1.getAccountNonce)(client, {
135
+ sender: accountAddress,
136
+ entryPoint: entryPointAddress
137
+ });
138
+ },
139
+ async signUserOperation(userOperation) {
140
+ return (0, actions_1.signMessage)(client, {
141
+ account: viemSigner,
142
+ message: {
143
+ raw: (0, getUserOperationHash_1.getUserOperationHash)({
144
+ userOperation,
145
+ entryPoint: entryPointAddress,
146
+ chainId: chainId
147
+ })
148
+ }
149
+ });
150
+ },
151
+ async getInitCode() {
152
+ if (smartAccountDeployed)
153
+ return "0x";
154
+ smartAccountDeployed = await (0, isSmartAccountDeployed_1.isSmartAccountDeployed)(client, accountAddress);
155
+ if (smartAccountDeployed)
156
+ return "0x";
157
+ return (0, viem_1.concatHex)([
158
+ factoryAddress,
159
+ await getAccountInitCode(viemSigner.address, index)
160
+ ]);
161
+ },
162
+ async getFactory() {
163
+ if (smartAccountDeployed)
164
+ return undefined;
165
+ smartAccountDeployed = await (0, isSmartAccountDeployed_1.isSmartAccountDeployed)(client, accountAddress);
166
+ if (smartAccountDeployed)
167
+ return undefined;
168
+ return factoryAddress;
169
+ },
170
+ async getFactoryData() {
171
+ if (smartAccountDeployed)
172
+ return undefined;
173
+ smartAccountDeployed = await (0, isSmartAccountDeployed_1.isSmartAccountDeployed)(client, accountAddress);
174
+ if (smartAccountDeployed)
175
+ return undefined;
176
+ return getAccountInitCode(viemSigner.address, index);
177
+ },
178
+ async encodeDeployCallData(_) {
179
+ throw new Error("Light account doesn't support account deployment");
180
+ },
181
+ async encodeCallData(args) {
182
+ if (Array.isArray(args)) {
183
+ const argsArray = args;
184
+ return (0, viem_1.encodeFunctionData)({
185
+ abi: [
186
+ {
187
+ inputs: [
188
+ {
189
+ internalType: "address[]",
190
+ name: "dest",
191
+ type: "address[]"
192
+ },
193
+ {
194
+ internalType: "uint256[]",
195
+ name: "value",
196
+ type: "uint256[]"
197
+ },
198
+ {
199
+ internalType: "bytes[]",
200
+ name: "func",
201
+ type: "bytes[]"
202
+ }
203
+ ],
204
+ name: "executeBatch",
205
+ outputs: [],
206
+ stateMutability: "nonpayable",
207
+ type: "function"
208
+ }
209
+ ],
210
+ functionName: "executeBatch",
211
+ args: [
212
+ argsArray.map((a) => a.to),
213
+ argsArray.map((a) => a.value),
214
+ argsArray.map((a) => a.data)
215
+ ]
216
+ });
217
+ }
218
+ const { to, value, data } = args;
219
+ return (0, viem_1.encodeFunctionData)({
220
+ abi: [
221
+ {
222
+ inputs: [
223
+ {
224
+ internalType: "address",
225
+ name: "dest",
226
+ type: "address"
227
+ },
228
+ {
229
+ internalType: "uint256",
230
+ name: "value",
231
+ type: "uint256"
232
+ },
233
+ {
234
+ internalType: "bytes",
235
+ name: "func",
236
+ type: "bytes"
237
+ }
238
+ ],
239
+ name: "execute",
240
+ outputs: [],
241
+ stateMutability: "nonpayable",
242
+ type: "function"
243
+ }
244
+ ],
245
+ functionName: "execute",
246
+ args: [to, value, data]
247
+ });
248
+ },
249
+ async getDummySignature(_userOperation) {
250
+ return "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";
251
+ }
252
+ });
253
+ }
254
+ exports.signerToLightSmartAccount = signerToLightSmartAccount;
255
+ //# sourceMappingURL=signerToLightSmartAccount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signerToLightSmartAccount.js","sourceRoot":"","sources":["../../../accounts/light/signerToLightSmartAccount.ts"],"names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AC,CAAC,IAAI,CAAC;qBAC/B;iBACJ,CAAC,CAAA;YACN,CAAC;YAED,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAI3B,CAAA;YAED,OAAO,IAAA,yBAAkB,EAAC;gBACtB,GAAG,EAAE;oBACD;wBACI,MAAM,EAAE;4BACJ;gCACI,YAAY,EAAE,SAAS;gCACvB,IAAI,EAAE,MAAM;gCACZ,IAAI,EAAE,SAAS;6BAClB;4BACD;gCACI,YAAY,EAAE,SAAS;gCACvB,IAAI,EAAE,OAAO;gCACb,IAAI,EAAE,SAAS;6BAClB;4BACD;gCACI,YAAY,EAAE,OAAO;gCACrB,IAAI,EAAE,MAAM;gCACZ,IAAI,EAAE,OAAO;6BAChB;yBACJ;wBACD,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,EAAE;wBACX,eAAe,EAAE,YAAY;wBAC7B,IAAI,EAAE,UAAU;qBACnB;iBACJ;gBACD,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC;aAC1B,CAAC,CAAA;QACN,CAAC;QACD,KAAK,CAAC,iBAAiB,CAAC,cAAc;YAClC,OAAO,sIAAsI,CAAA;QACjJ,CAAC;KACJ,CAAC,CAAA;AACN,CAAC;AA5ND,8DA4NC"}
@@ -1,5 +1,7 @@
1
1
  import { privateKeyToSimpleSmartAccount } from "./simple/privateKeyToSimpleSmartAccount.js";
2
2
  import { signerToSimpleSmartAccount } from "./simple/signerToSimpleSmartAccount.js";
3
+ import { privateKeyToLightSmartAccount } from "./light/privateKeyToLightSmartAccount.js";
4
+ import { signerToLightSmartAccount } from "./light/signerToLightSmartAccount.js";
3
5
  import { privateKeyToSafeSmartAccount } from "./safe/privateKeyToSafeSmartAccount.js";
4
6
  import { signerToSafeSmartAccount } from "./safe/signerToSafeSmartAccount.js";
5
7
  import { signerToEcdsaKernelSmartAccount } from "./kernel/signerToEcdsaKernelSmartAccount.js";
@@ -7,5 +9,5 @@ import { signerToBiconomySmartAccount } from "./biconomy/signerToBiconomySmartAc
7
9
  import { privateKeyToBiconomySmartAccount } from "./biconomy/privateKeyToBiconomySmartAccount.js";
8
10
  import { SignTransactionNotSupportedBySmartAccount } from "./types.js";
9
11
  import { toSmartAccount } from "./toSmartAccount.js";
10
- export { signerToSafeSmartAccount, signerToSimpleSmartAccount, SignTransactionNotSupportedBySmartAccount, privateKeyToBiconomySmartAccount, privateKeyToSimpleSmartAccount, privateKeyToSafeSmartAccount, signerToEcdsaKernelSmartAccount, signerToBiconomySmartAccount, toSmartAccount };
12
+ export { signerToSafeSmartAccount, signerToSimpleSmartAccount, signerToLightSmartAccount, SignTransactionNotSupportedBySmartAccount, privateKeyToBiconomySmartAccount, privateKeyToSimpleSmartAccount, privateKeyToLightSmartAccount, privateKeyToSafeSmartAccount, signerToEcdsaKernelSmartAccount, signerToBiconomySmartAccount, toSmartAccount };
11
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../accounts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,8BAA8B,EACjC,MAAM,yCAAyC,CAAA;AAEhD,OAAO,EAGH,0BAA0B,EAC7B,MAAM,qCAAqC,CAAA;AAE5C,OAAO,EAEH,4BAA4B,EAC/B,MAAM,qCAAqC,CAAA;AAE5C,OAAO,EAIH,wBAAwB,EAC3B,MAAM,iCAAiC,CAAA;AAExC,OAAO,EAGH,+BAA+B,EAClC,MAAM,0CAA0C,CAAA;AAEjD,OAAO,EAGH,4BAA4B,EAC/B,MAAM,yCAAyC,CAAA;AAEhD,OAAO,EAEH,gCAAgC,EACnC,MAAM,6CAA6C,CAAA;AAEpD,OAAO,EACH,yCAAyC,EAG5C,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,OAAO,EAIH,wBAAwB,EAExB,0BAA0B,EAC1B,yCAAyC,EACzC,gCAAgC,EAChC,8BAA8B,EAE9B,4BAA4B,EAE5B,+BAA+B,EAE/B,4BAA4B,EAC5B,cAAc,EAQjB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../accounts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,8BAA8B,EACjC,MAAM,yCAAyC,CAAA;AAEhD,OAAO,EAGH,0BAA0B,EAC7B,MAAM,qCAAqC,CAAA;AAE5C,OAAO,EAEH,6BAA6B,EAChC,MAAM,uCAAuC,CAAA;AAE9C,OAAO,EAGH,yBAAyB,EAC5B,MAAM,mCAAmC,CAAA;AAE1C,OAAO,EAEH,4BAA4B,EAC/B,MAAM,qCAAqC,CAAA;AAE5C,OAAO,EAIH,wBAAwB,EAC3B,MAAM,iCAAiC,CAAA;AAExC,OAAO,EAGH,+BAA+B,EAClC,MAAM,0CAA0C,CAAA;AAEjD,OAAO,EAGH,4BAA4B,EAC/B,MAAM,yCAAyC,CAAA;AAEhD,OAAO,EAEH,gCAAgC,EACnC,MAAM,6CAA6C,CAAA;AAEpD,OAAO,EACH,yCAAyC,EAG5C,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,OAAO,EAIH,wBAAwB,EAExB,0BAA0B,EAE1B,yBAAyB,EACzB,yCAAyC,EACzC,gCAAgC,EAChC,8BAA8B,EAC9B,6BAA6B,EAE7B,4BAA4B,EAE5B,+BAA+B,EAE/B,4BAA4B,EAC5B,cAAc,EAUjB,CAAA"}
@@ -0,0 +1,16 @@
1
+ import {} from "viem";
2
+ import { privateKeyToAccount } from "viem/accounts";
3
+ import { signerToLightSmartAccount } from "./signerToLightSmartAccount.js";
4
+ /**
5
+ * @description Creates an Simple Account from a private key.
6
+ *
7
+ * @returns A Private Key Simple Account.
8
+ */
9
+ export async function privateKeyToLightSmartAccount(client, { privateKey, ...rest }) {
10
+ const privateKeyAccount = privateKeyToAccount(privateKey);
11
+ return signerToLightSmartAccount(client, {
12
+ signer: privateKeyAccount,
13
+ ...rest
14
+ });
15
+ }
16
+ //# sourceMappingURL=privateKeyToLightSmartAccount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"privateKeyToLightSmartAccount.js","sourceRoot":"","sources":["../../../accounts/light/privateKeyToLightSmartAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqD,MAAM,MAAM,CAAA;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAEnD,OAAO,EAGH,yBAAyB,EAC5B,MAAM,6BAA6B,CAAA;AAUpC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,CAK/C,MAA6C,EAC7C,EAAE,UAAU,EAAE,GAAG,IAAI,EAAuD;IAE5E,MAAM,iBAAiB,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAA;IAEzD,OAAO,yBAAyB,CAAC,MAAM,EAAE;QACrC,MAAM,EAAE,iBAAiB;QACzB,GAAG,IAAI;KACV,CAAC,CAAA;AACN,CAAC"}
@@ -0,0 +1,257 @@
1
+ import { concatHex, encodeFunctionData, hashMessage, hashTypedData } from "viem";
2
+ import { getChainId, signMessage } from "viem/actions";
3
+ import { getAccountNonce } from "../../actions/public/getAccountNonce.js";
4
+ import { getSenderAddress } from "../../actions/public/getSenderAddress.js";
5
+ import { getEntryPointVersion } from "../../utils/index.js";
6
+ import { getUserOperationHash } from "../../utils/getUserOperationHash.js";
7
+ import { isSmartAccountDeployed } from "../../utils/isSmartAccountDeployed.js";
8
+ import { toSmartAccount } from "../toSmartAccount.js";
9
+ import { SignTransactionNotSupportedBySmartAccount } from "../types.js";
10
+ const getAccountInitCode = async (owner, index = BigInt(0)) => {
11
+ if (!owner)
12
+ throw new Error("Owner account not found");
13
+ return encodeFunctionData({
14
+ abi: [
15
+ {
16
+ inputs: [
17
+ {
18
+ internalType: "address",
19
+ name: "owner",
20
+ type: "address"
21
+ },
22
+ {
23
+ internalType: "uint256",
24
+ name: "salt",
25
+ type: "uint256"
26
+ }
27
+ ],
28
+ name: "createAccount",
29
+ outputs: [
30
+ {
31
+ internalType: "contract LightAccount",
32
+ name: "ret",
33
+ type: "address"
34
+ }
35
+ ],
36
+ stateMutability: "nonpayable",
37
+ type: "function"
38
+ }
39
+ ],
40
+ functionName: "createAccount",
41
+ args: [owner, index]
42
+ });
43
+ };
44
+ const getAccountAddress = async ({ client, factoryAddress, entryPoint: entryPointAddress, owner, index = BigInt(0) }) => {
45
+ const entryPointVersion = getEntryPointVersion(entryPointAddress);
46
+ const factoryData = await getAccountInitCode(owner, index);
47
+ if (entryPointVersion === "v0.6") {
48
+ return getSenderAddress(client, {
49
+ initCode: concatHex([factoryAddress, factoryData]),
50
+ entryPoint: entryPointAddress
51
+ });
52
+ }
53
+ // Get the sender address based on the init code
54
+ return getSenderAddress(client, {
55
+ factory: factoryAddress,
56
+ factoryData,
57
+ entryPoint: entryPointAddress
58
+ });
59
+ };
60
+ async function signWith1271WrapperV1(signer, chainId, accountAddress, hashedMessage) {
61
+ return signer.signTypedData({
62
+ domain: {
63
+ chainId: Number(chainId),
64
+ name: "LightAccount",
65
+ verifyingContract: accountAddress,
66
+ version: "1"
67
+ },
68
+ types: {
69
+ LightAccountMessage: [{ name: "message", type: "bytes" }]
70
+ },
71
+ message: {
72
+ message: hashedMessage
73
+ },
74
+ primaryType: "LightAccountMessage"
75
+ });
76
+ }
77
+ const LIGHT_VERSION_TO_ADDRESSES_MAP = {
78
+ "v1.1.0": {
79
+ factoryAddress: "0x00004EC70002a32400f8ae005A26081065620D20"
80
+ }
81
+ };
82
+ const getDefaultAddresses = (lightVersion, { factoryAddress: _factoryAddress }) => {
83
+ const factoryAddress = _factoryAddress ??
84
+ LIGHT_VERSION_TO_ADDRESSES_MAP[lightVersion].factoryAddress;
85
+ return {
86
+ factoryAddress
87
+ };
88
+ };
89
+ /**
90
+ * @description Creates an Light Account from a private key.
91
+ *
92
+ * @returns A Private Key Light Account.
93
+ */
94
+ export async function signerToLightSmartAccount(client, { signer, address, lightVersion, entryPoint: entryPointAddress, index = BigInt(0), factoryAddress: _factoryAddress }) {
95
+ const viemSigner = {
96
+ ...signer,
97
+ signTransaction: (_, __) => {
98
+ throw new SignTransactionNotSupportedBySmartAccount();
99
+ }
100
+ };
101
+ if (lightVersion !== "v1.1.0") {
102
+ throw new Error("Only Light Account version v1.1.0 is supported at the moment");
103
+ }
104
+ const { factoryAddress } = getDefaultAddresses(lightVersion, {
105
+ factoryAddress: _factoryAddress
106
+ });
107
+ const [accountAddress, chainId] = await Promise.all([
108
+ address ??
109
+ getAccountAddress({
110
+ client,
111
+ factoryAddress,
112
+ entryPoint: entryPointAddress,
113
+ owner: viemSigner.address,
114
+ index
115
+ }),
116
+ client.chain?.id ?? getChainId(client)
117
+ ]);
118
+ if (!accountAddress)
119
+ throw new Error("Account address not found");
120
+ let smartAccountDeployed = await isSmartAccountDeployed(client, accountAddress);
121
+ return toSmartAccount({
122
+ address: accountAddress,
123
+ signMessage: async ({ message }) => {
124
+ return signWith1271WrapperV1(signer, chainId, accountAddress, hashMessage(message));
125
+ },
126
+ signTransaction: (_, __) => {
127
+ throw new SignTransactionNotSupportedBySmartAccount();
128
+ },
129
+ async signTypedData(typedData) {
130
+ return signWith1271WrapperV1(signer, chainId, accountAddress, hashTypedData(typedData));
131
+ },
132
+ client: client,
133
+ publicKey: accountAddress,
134
+ entryPoint: entryPointAddress,
135
+ source: "LightSmartAccount",
136
+ async getNonce() {
137
+ return getAccountNonce(client, {
138
+ sender: accountAddress,
139
+ entryPoint: entryPointAddress
140
+ });
141
+ },
142
+ async signUserOperation(userOperation) {
143
+ return signMessage(client, {
144
+ account: viemSigner,
145
+ message: {
146
+ raw: getUserOperationHash({
147
+ userOperation,
148
+ entryPoint: entryPointAddress,
149
+ chainId: chainId
150
+ })
151
+ }
152
+ });
153
+ },
154
+ async getInitCode() {
155
+ if (smartAccountDeployed)
156
+ return "0x";
157
+ smartAccountDeployed = await isSmartAccountDeployed(client, accountAddress);
158
+ if (smartAccountDeployed)
159
+ return "0x";
160
+ return concatHex([
161
+ factoryAddress,
162
+ await getAccountInitCode(viemSigner.address, index)
163
+ ]);
164
+ },
165
+ async getFactory() {
166
+ if (smartAccountDeployed)
167
+ return undefined;
168
+ smartAccountDeployed = await isSmartAccountDeployed(client, accountAddress);
169
+ if (smartAccountDeployed)
170
+ return undefined;
171
+ return factoryAddress;
172
+ },
173
+ async getFactoryData() {
174
+ if (smartAccountDeployed)
175
+ return undefined;
176
+ smartAccountDeployed = await isSmartAccountDeployed(client, accountAddress);
177
+ if (smartAccountDeployed)
178
+ return undefined;
179
+ return getAccountInitCode(viemSigner.address, index);
180
+ },
181
+ async encodeDeployCallData(_) {
182
+ throw new Error("Light account doesn't support account deployment");
183
+ },
184
+ async encodeCallData(args) {
185
+ if (Array.isArray(args)) {
186
+ const argsArray = args;
187
+ return encodeFunctionData({
188
+ abi: [
189
+ {
190
+ inputs: [
191
+ {
192
+ internalType: "address[]",
193
+ name: "dest",
194
+ type: "address[]"
195
+ },
196
+ {
197
+ internalType: "uint256[]",
198
+ name: "value",
199
+ type: "uint256[]"
200
+ },
201
+ {
202
+ internalType: "bytes[]",
203
+ name: "func",
204
+ type: "bytes[]"
205
+ }
206
+ ],
207
+ name: "executeBatch",
208
+ outputs: [],
209
+ stateMutability: "nonpayable",
210
+ type: "function"
211
+ }
212
+ ],
213
+ functionName: "executeBatch",
214
+ args: [
215
+ argsArray.map((a) => a.to),
216
+ argsArray.map((a) => a.value),
217
+ argsArray.map((a) => a.data)
218
+ ]
219
+ });
220
+ }
221
+ const { to, value, data } = args;
222
+ return encodeFunctionData({
223
+ abi: [
224
+ {
225
+ inputs: [
226
+ {
227
+ internalType: "address",
228
+ name: "dest",
229
+ type: "address"
230
+ },
231
+ {
232
+ internalType: "uint256",
233
+ name: "value",
234
+ type: "uint256"
235
+ },
236
+ {
237
+ internalType: "bytes",
238
+ name: "func",
239
+ type: "bytes"
240
+ }
241
+ ],
242
+ name: "execute",
243
+ outputs: [],
244
+ stateMutability: "nonpayable",
245
+ type: "function"
246
+ }
247
+ ],
248
+ functionName: "execute",
249
+ args: [to, value, data]
250
+ });
251
+ },
252
+ async getDummySignature(_userOperation) {
253
+ return "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";
254
+ }
255
+ });
256
+ }
257
+ //# sourceMappingURL=signerToLightSmartAccount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signerToLightSmartAccount.js","sourceRoot":"","sources":["../../../accounts/light/signerToLightSmartAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EASH,SAAS,EACT,kBAAkB,EAClB,WAAW,EACX,aAAa,EAChB,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAA;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAA;AAOxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAA;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAA;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EACH,yCAAyC,EAG5C,MAAM,UAAU,CAAA;AAQjB,MAAM,kBAAkB,GAAG,KAAK,EAC5B,KAAc,EACd,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,EACL,EAAE;IACd,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAEtD,OAAO,kBAAkB,CAAC;QACtB,GAAG,EAAE;YACD;gBACI,MAAM,EAAE;oBACJ;wBACI,YAAY,EAAE,SAAS;wBACvB,IAAI,EAAE,OAAO;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wBACX,eAAe,EAAE,YAAY;wBAC7B,IAAI,EAAE,UAAU;qBACnB;iBACJ;gBACD,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC;aAC1B,CAAC,CAAA;QACN,CAAC;QACD,KAAK,CAAC,iBAAiB,CAAC,cAAc;YAClC,OAAO,sIAAsI,CAAA;QACjJ,CAAC;KACJ,CAAC,CAAA;AACN,CAAC"}
@@ -1,5 +1,7 @@
1
1
  import { type PrivateKeyToSimpleSmartAccountParameters, privateKeyToSimpleSmartAccount } from "./simple/privateKeyToSimpleSmartAccount";
2
2
  import { type SignerToSimpleSmartAccountParameters, type SimpleSmartAccount, signerToSimpleSmartAccount } from "./simple/signerToSimpleSmartAccount";
3
+ import { type PrivateKeyToLightSmartAccountParameters, privateKeyToLightSmartAccount } from "./light/privateKeyToLightSmartAccount";
4
+ import { type LightSmartAccount, type SignerToLightSmartAccountParameters, signerToLightSmartAccount } from "./light/signerToLightSmartAccount";
3
5
  import { type PrivateKeyToSafeSmartAccountParameters, privateKeyToSafeSmartAccount } from "./safe/privateKeyToSafeSmartAccount";
4
6
  import { type SafeSmartAccount, type SafeVersion, type SignerToSafeSmartAccountParameters, signerToSafeSmartAccount } from "./safe/signerToSafeSmartAccount";
5
7
  import { type KernelEcdsaSmartAccount, type SignerToEcdsaKernelSmartAccountParameters, signerToEcdsaKernelSmartAccount } from "./kernel/signerToEcdsaKernelSmartAccount";
@@ -7,5 +9,5 @@ import { type BiconomySmartAccount, type SignerToBiconomySmartAccountParameters,
7
9
  import { type PrivateKeyToBiconomySmartAccountParameters, privateKeyToBiconomySmartAccount } from "./biconomy/privateKeyToBiconomySmartAccount";
8
10
  import { SignTransactionNotSupportedBySmartAccount, type SmartAccount, type SmartAccountSigner } from "./types";
9
11
  import { toSmartAccount } from "./toSmartAccount";
10
- export { type SafeVersion, type SmartAccountSigner, type SafeSmartAccount, signerToSafeSmartAccount, type SimpleSmartAccount, signerToSimpleSmartAccount, SignTransactionNotSupportedBySmartAccount, privateKeyToBiconomySmartAccount, privateKeyToSimpleSmartAccount, type SmartAccount, privateKeyToSafeSmartAccount, type KernelEcdsaSmartAccount, signerToEcdsaKernelSmartAccount, type BiconomySmartAccount, signerToBiconomySmartAccount, toSmartAccount, type SignerToSimpleSmartAccountParameters, type SignerToSafeSmartAccountParameters, type PrivateKeyToSimpleSmartAccountParameters, type PrivateKeyToSafeSmartAccountParameters, type SignerToEcdsaKernelSmartAccountParameters, type SignerToBiconomySmartAccountParameters, type PrivateKeyToBiconomySmartAccountParameters };
12
+ export { type SafeVersion, type SmartAccountSigner, type SafeSmartAccount, signerToSafeSmartAccount, type SimpleSmartAccount, signerToSimpleSmartAccount, type LightSmartAccount, signerToLightSmartAccount, SignTransactionNotSupportedBySmartAccount, privateKeyToBiconomySmartAccount, privateKeyToSimpleSmartAccount, privateKeyToLightSmartAccount, type SmartAccount, privateKeyToSafeSmartAccount, type KernelEcdsaSmartAccount, signerToEcdsaKernelSmartAccount, type BiconomySmartAccount, signerToBiconomySmartAccount, toSmartAccount, type SignerToSimpleSmartAccountParameters, type SignerToLightSmartAccountParameters, type SignerToSafeSmartAccountParameters, type PrivateKeyToSimpleSmartAccountParameters, type PrivateKeyToLightSmartAccountParameters, type PrivateKeyToSafeSmartAccountParameters, type SignerToEcdsaKernelSmartAccountParameters, type SignerToBiconomySmartAccountParameters, type PrivateKeyToBiconomySmartAccountParameters };
11
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../accounts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,wCAAwC,EAC7C,8BAA8B,EACjC,MAAM,yCAAyC,CAAA;AAEhD,OAAO,EACH,KAAK,oCAAoC,EACzC,KAAK,kBAAkB,EACvB,0BAA0B,EAC7B,MAAM,qCAAqC,CAAA;AAE5C,OAAO,EACH,KAAK,sCAAsC,EAC3C,4BAA4B,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,KAAK,yCAAyC,EAC9C,KAAK,sCAAsC,EAC3C,KAAK,0CAA0C,EAClD,CAAA"}
@@ -0,0 +1,13 @@
1
+ import { type Chain, type Client, type Hex, type Transport } from "viem";
2
+ import type { ENTRYPOINT_ADDRESS_V06_TYPE, Prettify } from "../../types";
3
+ import { type LightSmartAccount, type SignerToLightSmartAccountParameters } from "./signerToLightSmartAccount";
4
+ export type PrivateKeyToLightSmartAccountParameters<entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE> = Prettify<{
5
+ privateKey: Hex;
6
+ } & Omit<SignerToLightSmartAccountParameters<entryPoint>, "signer">>;
7
+ /**
8
+ * @description Creates an Simple Account from a private key.
9
+ *
10
+ * @returns A Private Key Simple Account.
11
+ */
12
+ export declare function privateKeyToLightSmartAccount<entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE, TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined>(client: Client<TTransport, TChain, undefined>, { privateKey, ...rest }: PrivateKeyToLightSmartAccountParameters<entryPoint>): Promise<LightSmartAccount<entryPoint, TTransport, TChain>>;
13
+ //# sourceMappingURL=privateKeyToLightSmartAccount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"privateKeyToLightSmartAccount.d.ts","sourceRoot":"","sources":["../../../accounts/light/privateKeyToLightSmartAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,MAAM,EAAE,KAAK,GAAG,EAAE,KAAK,SAAS,EAAE,MAAM,MAAM,CAAA;AAExE,OAAO,KAAK,EAAE,2BAA2B,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACxE,OAAO,EACH,KAAK,iBAAiB,EACtB,KAAK,mCAAmC,EAE3C,MAAM,6BAA6B,CAAA;AAEpC,MAAM,MAAM,uCAAuC,CAC/C,UAAU,SAAS,2BAA2B,IAC9C,QAAQ,CACR;IACI,UAAU,EAAE,GAAG,CAAA;CAClB,GAAG,IAAI,CAAC,mCAAmC,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,CACtE,CAAA;AAED;;;;GAIG;AACH,wBAAsB,6BAA6B,CAC/C,UAAU,SAAS,2BAA2B,EAC9C,UAAU,SAAS,SAAS,GAAG,SAAS,EACxC,MAAM,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EAEpD,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,EAC7C,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,EAAE,uCAAuC,CAAC,UAAU,CAAC,GAC7E,OAAO,CAAC,iBAAiB,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC,CAO5D"}
@@ -0,0 +1,21 @@
1
+ import { type Address, type Chain, type Client, type Transport } from "viem";
2
+ import type { Prettify } from "../../types";
3
+ import type { EntryPoint } from "../../types/entrypoint";
4
+ import { type SmartAccount, type SmartAccountSigner } from "../types";
5
+ export type LightSmartAccount<entryPoint extends EntryPoint, transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined> = SmartAccount<entryPoint, "LightSmartAccount", transport, chain>;
6
+ export type LightVersion = "v1.1.0";
7
+ export type SignerToLightSmartAccountParameters<entryPoint extends EntryPoint, TSource extends string = string, TAddress extends Address = Address> = Prettify<{
8
+ signer: SmartAccountSigner<TSource, TAddress>;
9
+ lightVersion: LightVersion;
10
+ entryPoint: entryPoint;
11
+ factoryAddress?: Address;
12
+ index?: bigint;
13
+ address?: Address;
14
+ }>;
15
+ /**
16
+ * @description Creates an Light Account from a private key.
17
+ *
18
+ * @returns A Private Key Light Account.
19
+ */
20
+ export declare function signerToLightSmartAccount<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, undefined>, { signer, address, lightVersion, entryPoint: entryPointAddress, index, factoryAddress: _factoryAddress }: SignerToLightSmartAccountParameters<entryPoint, TSource, TAddress>): Promise<LightSmartAccount<entryPoint, TTransport, TChain>>;
21
+ //# sourceMappingURL=signerToLightSmartAccount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signerToLightSmartAccount.d.ts","sourceRoot":"","sources":["../../../accounts/light/signerToLightSmartAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,MAAM,EAGX,KAAK,SAAS,EAOjB,MAAM,MAAM,CAAA;AAIb,OAAO,KAAK,EAGR,QAAQ,EACX,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAKxD,OAAO,EAEH,KAAK,YAAY,EACjB,KAAK,kBAAkB,EAC1B,MAAM,UAAU,CAAA;AAEjB,MAAM,MAAM,iBAAiB,CACzB,UAAU,SAAS,UAAU,EAC7B,SAAS,SAAS,SAAS,GAAG,SAAS,EACvC,KAAK,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,IACnD,YAAY,CAAC,UAAU,EAAE,mBAAmB,EAAE,SAAS,EAAE,KAAK,CAAC,CAAA;AA4EnE,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAA;AAEnC,MAAM,MAAM,mCAAmC,CAC3C,UAAU,SAAS,UAAU,EAC7B,OAAO,SAAS,MAAM,GAAG,MAAM,EAC/B,QAAQ,SAAS,OAAO,GAAG,OAAO,IAClC,QAAQ,CAAC;IACT,MAAM,EAAE,kBAAkB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;IAC7C,YAAY,EAAE,YAAY,CAAA;IAC1B,UAAU,EAAE,UAAU,CAAA;IACtB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,OAAO,CAAA;CACpB,CAAC,CAAA;AAuDF;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC3C,UAAU,SAAS,UAAU,EAC7B,UAAU,SAAS,SAAS,GAAG,SAAS,EACxC,MAAM,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EACpD,OAAO,SAAS,MAAM,GAAG,MAAM,EAC/B,QAAQ,SAAS,OAAO,GAAG,OAAO,EAElC,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,EAC7C,EACI,MAAM,EACN,OAAO,EACP,YAAY,EACZ,UAAU,EAAE,iBAAiB,EAC7B,KAAiB,EACjB,cAAc,EAAE,eAAe,EAClC,EAAE,mCAAmC,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,GACtE,OAAO,CAAC,iBAAiB,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC,CA4M5D"}
package/accounts/index.ts CHANGED
@@ -9,6 +9,17 @@ import {
9
9
  signerToSimpleSmartAccount
10
10
  } from "./simple/signerToSimpleSmartAccount"
11
11
 
12
+ import {
13
+ type PrivateKeyToLightSmartAccountParameters,
14
+ privateKeyToLightSmartAccount
15
+ } from "./light/privateKeyToLightSmartAccount"
16
+
17
+ import {
18
+ type LightSmartAccount,
19
+ type SignerToLightSmartAccountParameters,
20
+ signerToLightSmartAccount
21
+ } from "./light/signerToLightSmartAccount"
22
+
12
23
  import {
13
24
  type PrivateKeyToSafeSmartAccountParameters,
14
25
  privateKeyToSafeSmartAccount
@@ -53,9 +64,12 @@ export {
53
64
  signerToSafeSmartAccount,
54
65
  type SimpleSmartAccount,
55
66
  signerToSimpleSmartAccount,
67
+ type LightSmartAccount,
68
+ signerToLightSmartAccount,
56
69
  SignTransactionNotSupportedBySmartAccount,
57
70
  privateKeyToBiconomySmartAccount,
58
71
  privateKeyToSimpleSmartAccount,
72
+ privateKeyToLightSmartAccount,
59
73
  type SmartAccount,
60
74
  privateKeyToSafeSmartAccount,
61
75
  type KernelEcdsaSmartAccount,
@@ -64,8 +78,10 @@ export {
64
78
  signerToBiconomySmartAccount,
65
79
  toSmartAccount,
66
80
  type SignerToSimpleSmartAccountParameters,
81
+ type SignerToLightSmartAccountParameters,
67
82
  type SignerToSafeSmartAccountParameters,
68
83
  type PrivateKeyToSimpleSmartAccountParameters,
84
+ type PrivateKeyToLightSmartAccountParameters,
69
85
  type PrivateKeyToSafeSmartAccountParameters,
70
86
  type SignerToEcdsaKernelSmartAccountParameters,
71
87
  type SignerToBiconomySmartAccountParameters,
@@ -0,0 +1,37 @@
1
+ import { type Chain, type Client, type Hex, type Transport } from "viem"
2
+ import { privateKeyToAccount } from "viem/accounts"
3
+ import type { ENTRYPOINT_ADDRESS_V06_TYPE, Prettify } from "../../types"
4
+ import {
5
+ type LightSmartAccount,
6
+ type SignerToLightSmartAccountParameters,
7
+ signerToLightSmartAccount
8
+ } from "./signerToLightSmartAccount"
9
+
10
+ export type PrivateKeyToLightSmartAccountParameters<
11
+ entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE
12
+ > = Prettify<
13
+ {
14
+ privateKey: Hex
15
+ } & Omit<SignerToLightSmartAccountParameters<entryPoint>, "signer">
16
+ >
17
+
18
+ /**
19
+ * @description Creates an Simple Account from a private key.
20
+ *
21
+ * @returns A Private Key Simple Account.
22
+ */
23
+ export async function privateKeyToLightSmartAccount<
24
+ entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE,
25
+ TTransport extends Transport = Transport,
26
+ TChain extends Chain | undefined = Chain | undefined
27
+ >(
28
+ client: Client<TTransport, TChain, undefined>,
29
+ { privateKey, ...rest }: PrivateKeyToLightSmartAccountParameters<entryPoint>
30
+ ): Promise<LightSmartAccount<entryPoint, TTransport, TChain>> {
31
+ const privateKeyAccount = privateKeyToAccount(privateKey)
32
+
33
+ return signerToLightSmartAccount(client, {
34
+ signer: privateKeyAccount,
35
+ ...rest
36
+ })
37
+ }
@@ -0,0 +1,407 @@
1
+ import {
2
+ type Address,
3
+ type Chain,
4
+ type Client,
5
+ type Hex,
6
+ type LocalAccount,
7
+ type Transport,
8
+ type TypedData,
9
+ type TypedDataDefinition,
10
+ concatHex,
11
+ encodeFunctionData,
12
+ hashMessage,
13
+ hashTypedData
14
+ } from "viem"
15
+ import { getChainId, signMessage } from "viem/actions"
16
+ import { getAccountNonce } from "../../actions/public/getAccountNonce"
17
+ import { getSenderAddress } from "../../actions/public/getSenderAddress"
18
+ import type {
19
+ ENTRYPOINT_ADDRESS_V06_TYPE,
20
+ ENTRYPOINT_ADDRESS_V07_TYPE,
21
+ Prettify
22
+ } from "../../types"
23
+ import type { EntryPoint } from "../../types/entrypoint"
24
+ import { getEntryPointVersion } from "../../utils"
25
+ import { getUserOperationHash } from "../../utils/getUserOperationHash"
26
+ import { isSmartAccountDeployed } from "../../utils/isSmartAccountDeployed"
27
+ import { toSmartAccount } from "../toSmartAccount"
28
+ import {
29
+ SignTransactionNotSupportedBySmartAccount,
30
+ type SmartAccount,
31
+ type SmartAccountSigner
32
+ } from "../types"
33
+
34
+ export type LightSmartAccount<
35
+ entryPoint extends EntryPoint,
36
+ transport extends Transport = Transport,
37
+ chain extends Chain | undefined = Chain | undefined
38
+ > = SmartAccount<entryPoint, "LightSmartAccount", transport, chain>
39
+
40
+ const getAccountInitCode = async (
41
+ owner: Address,
42
+ index = BigInt(0)
43
+ ): Promise<Hex> => {
44
+ if (!owner) throw new Error("Owner account not found")
45
+
46
+ return encodeFunctionData({
47
+ abi: [
48
+ {
49
+ inputs: [
50
+ {
51
+ internalType: "address",
52
+ name: "owner",
53
+ type: "address"
54
+ },
55
+ {
56
+ internalType: "uint256",
57
+ name: "salt",
58
+ type: "uint256"
59
+ }
60
+ ],
61
+ name: "createAccount",
62
+ outputs: [
63
+ {
64
+ internalType: "contract LightAccount",
65
+ name: "ret",
66
+ type: "address"
67
+ }
68
+ ],
69
+ stateMutability: "nonpayable",
70
+ type: "function"
71
+ }
72
+ ],
73
+ functionName: "createAccount",
74
+ args: [owner, index]
75
+ })
76
+ }
77
+
78
+ const getAccountAddress = async <
79
+ entryPoint extends EntryPoint,
80
+ TTransport extends Transport = Transport,
81
+ TChain extends Chain | undefined = Chain | undefined
82
+ >({
83
+ client,
84
+ factoryAddress,
85
+ entryPoint: entryPointAddress,
86
+ owner,
87
+ index = BigInt(0)
88
+ }: {
89
+ client: Client<TTransport, TChain>
90
+ factoryAddress: Address
91
+ owner: Address
92
+ entryPoint: entryPoint
93
+ index?: bigint
94
+ }): Promise<Address> => {
95
+ const entryPointVersion = getEntryPointVersion(entryPointAddress)
96
+
97
+ const factoryData = await getAccountInitCode(owner, index)
98
+
99
+ if (entryPointVersion === "v0.6") {
100
+ return getSenderAddress<ENTRYPOINT_ADDRESS_V06_TYPE>(client, {
101
+ initCode: concatHex([factoryAddress, factoryData]),
102
+ entryPoint: entryPointAddress as ENTRYPOINT_ADDRESS_V06_TYPE
103
+ })
104
+ }
105
+
106
+ // Get the sender address based on the init code
107
+ return getSenderAddress<ENTRYPOINT_ADDRESS_V07_TYPE>(client, {
108
+ factory: factoryAddress,
109
+ factoryData,
110
+ entryPoint: entryPointAddress as ENTRYPOINT_ADDRESS_V07_TYPE
111
+ })
112
+ }
113
+
114
+ export type LightVersion = "v1.1.0"
115
+
116
+ export type SignerToLightSmartAccountParameters<
117
+ entryPoint extends EntryPoint,
118
+ TSource extends string = string,
119
+ TAddress extends Address = Address
120
+ > = Prettify<{
121
+ signer: SmartAccountSigner<TSource, TAddress>
122
+ lightVersion: LightVersion
123
+ entryPoint: entryPoint
124
+ factoryAddress?: Address
125
+ index?: bigint
126
+ address?: Address
127
+ }>
128
+
129
+ async function signWith1271WrapperV1<
130
+ TSource extends string = string,
131
+ TAddress extends Address = Address
132
+ >(
133
+ signer: SmartAccountSigner<TSource, TAddress>,
134
+ chainId: number,
135
+ accountAddress: Address,
136
+ hashedMessage: Hex
137
+ ): Promise<Hex> {
138
+ return signer.signTypedData({
139
+ domain: {
140
+ chainId: Number(chainId),
141
+ name: "LightAccount",
142
+ verifyingContract: accountAddress,
143
+ version: "1"
144
+ },
145
+ types: {
146
+ LightAccountMessage: [{ name: "message", type: "bytes" }]
147
+ },
148
+ message: {
149
+ message: hashedMessage
150
+ },
151
+ primaryType: "LightAccountMessage"
152
+ })
153
+ }
154
+
155
+ const LIGHT_VERSION_TO_ADDRESSES_MAP: {
156
+ [key in LightVersion]: {
157
+ factoryAddress: Address
158
+ }
159
+ } = {
160
+ "v1.1.0": {
161
+ factoryAddress: "0x00004EC70002a32400f8ae005A26081065620D20"
162
+ }
163
+ }
164
+
165
+ const getDefaultAddresses = (
166
+ lightVersion: LightVersion,
167
+ {
168
+ factoryAddress: _factoryAddress
169
+ }: {
170
+ factoryAddress?: Address
171
+ }
172
+ ) => {
173
+ const factoryAddress =
174
+ _factoryAddress ??
175
+ LIGHT_VERSION_TO_ADDRESSES_MAP[lightVersion].factoryAddress
176
+
177
+ return {
178
+ factoryAddress
179
+ }
180
+ }
181
+
182
+ /**
183
+ * @description Creates an Light Account from a private key.
184
+ *
185
+ * @returns A Private Key Light Account.
186
+ */
187
+ export async function signerToLightSmartAccount<
188
+ entryPoint extends EntryPoint,
189
+ TTransport extends Transport = Transport,
190
+ TChain extends Chain | undefined = Chain | undefined,
191
+ TSource extends string = string,
192
+ TAddress extends Address = Address
193
+ >(
194
+ client: Client<TTransport, TChain, undefined>,
195
+ {
196
+ signer,
197
+ address,
198
+ lightVersion,
199
+ entryPoint: entryPointAddress,
200
+ index = BigInt(0),
201
+ factoryAddress: _factoryAddress
202
+ }: SignerToLightSmartAccountParameters<entryPoint, TSource, TAddress>
203
+ ): Promise<LightSmartAccount<entryPoint, TTransport, TChain>> {
204
+ const viemSigner: LocalAccount = {
205
+ ...signer,
206
+ signTransaction: (_, __) => {
207
+ throw new SignTransactionNotSupportedBySmartAccount()
208
+ }
209
+ } as LocalAccount
210
+
211
+ if (lightVersion !== "v1.1.0") {
212
+ throw new Error(
213
+ "Only Light Account version v1.1.0 is supported at the moment"
214
+ )
215
+ }
216
+
217
+ const { factoryAddress } = getDefaultAddresses(lightVersion, {
218
+ factoryAddress: _factoryAddress
219
+ })
220
+
221
+ const [accountAddress, chainId] = await Promise.all([
222
+ address ??
223
+ getAccountAddress<entryPoint, TTransport, TChain>({
224
+ client,
225
+ factoryAddress,
226
+ entryPoint: entryPointAddress,
227
+ owner: viemSigner.address,
228
+ index
229
+ }),
230
+ client.chain?.id ?? getChainId(client)
231
+ ])
232
+
233
+ if (!accountAddress) throw new Error("Account address not found")
234
+
235
+ let smartAccountDeployed = await isSmartAccountDeployed(
236
+ client,
237
+ accountAddress
238
+ )
239
+
240
+ return toSmartAccount({
241
+ address: accountAddress,
242
+ signMessage: async ({ message }) => {
243
+ return signWith1271WrapperV1<TSource, TAddress>(
244
+ signer,
245
+ chainId,
246
+ accountAddress,
247
+ hashMessage(message)
248
+ )
249
+ },
250
+ signTransaction: (_, __) => {
251
+ throw new SignTransactionNotSupportedBySmartAccount()
252
+ },
253
+ async signTypedData<
254
+ const TTypedData extends TypedData | Record<string, unknown>,
255
+ TPrimaryType extends
256
+ | keyof TTypedData
257
+ | "EIP712Domain" = keyof TTypedData
258
+ >(typedData: TypedDataDefinition<TTypedData, TPrimaryType>) {
259
+ return signWith1271WrapperV1<TSource, TAddress>(
260
+ signer,
261
+ chainId,
262
+ accountAddress,
263
+ hashTypedData(typedData)
264
+ )
265
+ },
266
+ client: client,
267
+ publicKey: accountAddress,
268
+ entryPoint: entryPointAddress,
269
+ source: "LightSmartAccount",
270
+ async getNonce() {
271
+ return getAccountNonce(client, {
272
+ sender: accountAddress,
273
+ entryPoint: entryPointAddress
274
+ })
275
+ },
276
+ async signUserOperation(userOperation) {
277
+ return signMessage(client, {
278
+ account: viemSigner,
279
+ message: {
280
+ raw: getUserOperationHash({
281
+ userOperation,
282
+ entryPoint: entryPointAddress,
283
+ chainId: chainId
284
+ })
285
+ }
286
+ })
287
+ },
288
+ async getInitCode() {
289
+ if (smartAccountDeployed) return "0x"
290
+
291
+ smartAccountDeployed = await isSmartAccountDeployed(
292
+ client,
293
+ accountAddress
294
+ )
295
+
296
+ if (smartAccountDeployed) return "0x"
297
+
298
+ return concatHex([
299
+ factoryAddress,
300
+ await getAccountInitCode(viemSigner.address, index)
301
+ ])
302
+ },
303
+ async getFactory() {
304
+ if (smartAccountDeployed) return undefined
305
+ smartAccountDeployed = await isSmartAccountDeployed(
306
+ client,
307
+ accountAddress
308
+ )
309
+ if (smartAccountDeployed) return undefined
310
+ return factoryAddress
311
+ },
312
+ async getFactoryData() {
313
+ if (smartAccountDeployed) return undefined
314
+ smartAccountDeployed = await isSmartAccountDeployed(
315
+ client,
316
+ accountAddress
317
+ )
318
+ if (smartAccountDeployed) return undefined
319
+ return getAccountInitCode(viemSigner.address, index)
320
+ },
321
+ async encodeDeployCallData(_) {
322
+ throw new Error("Light account doesn't support account deployment")
323
+ },
324
+ async encodeCallData(args) {
325
+ if (Array.isArray(args)) {
326
+ const argsArray = args as {
327
+ to: Address
328
+ value: bigint
329
+ data: Hex
330
+ }[]
331
+
332
+ return encodeFunctionData({
333
+ abi: [
334
+ {
335
+ inputs: [
336
+ {
337
+ internalType: "address[]",
338
+ name: "dest",
339
+ type: "address[]"
340
+ },
341
+ {
342
+ internalType: "uint256[]",
343
+ name: "value",
344
+ type: "uint256[]"
345
+ },
346
+ {
347
+ internalType: "bytes[]",
348
+ name: "func",
349
+ type: "bytes[]"
350
+ }
351
+ ],
352
+ name: "executeBatch",
353
+ outputs: [],
354
+ stateMutability: "nonpayable",
355
+ type: "function"
356
+ }
357
+ ],
358
+ functionName: "executeBatch",
359
+ args: [
360
+ argsArray.map((a) => a.to),
361
+ argsArray.map((a) => a.value),
362
+ argsArray.map((a) => a.data)
363
+ ]
364
+ })
365
+ }
366
+
367
+ const { to, value, data } = args as {
368
+ to: Address
369
+ value: bigint
370
+ data: Hex
371
+ }
372
+
373
+ return encodeFunctionData({
374
+ abi: [
375
+ {
376
+ inputs: [
377
+ {
378
+ internalType: "address",
379
+ name: "dest",
380
+ type: "address"
381
+ },
382
+ {
383
+ internalType: "uint256",
384
+ name: "value",
385
+ type: "uint256"
386
+ },
387
+ {
388
+ internalType: "bytes",
389
+ name: "func",
390
+ type: "bytes"
391
+ }
392
+ ],
393
+ name: "execute",
394
+ outputs: [],
395
+ stateMutability: "nonpayable",
396
+ type: "function"
397
+ }
398
+ ],
399
+ functionName: "execute",
400
+ args: [to, value, data]
401
+ })
402
+ },
403
+ async getDummySignature(_userOperation) {
404
+ return "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"
405
+ }
406
+ })
407
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "permissionless",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "author": "Pimlico",
5
5
  "homepage": "https://docs.pimlico.io/permissionless",
6
6
  "repository": "github:pimlicolabs/permissionless.js",