@charterlabs/rhinestone-sdk 0.2.7-dev.2 → 0.2.7-dev.4
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/dist/src/accounts/error.d.ts +38 -3
- package/dist/src/accounts/error.d.ts.map +1 -1
- package/dist/src/accounts/error.js +55 -7
- package/dist/src/accounts/index.d.ts +28 -20
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +196 -21
- package/dist/src/accounts/index.test.js +2 -4
- package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -1
- package/dist/src/accounts/json-rpc/providers.js +42 -4
- package/dist/src/accounts/kernel.d.ts +1 -1
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +29 -1
- package/dist/src/accounts/kernel.test.js +35 -8
- package/dist/src/accounts/nexus.d.ts +4 -3
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +82 -14
- package/dist/src/accounts/nexus.test.js +33 -6
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +85 -53
- package/dist/src/accounts/safe.test.js +33 -6
- package/dist/src/accounts/signing/common.d.ts +4 -4
- package/dist/src/accounts/signing/common.d.ts.map +1 -1
- package/dist/src/accounts/signing/common.js +21 -9
- package/dist/src/accounts/signing/message.d.ts +1 -1
- package/dist/src/accounts/signing/message.d.ts.map +1 -1
- package/dist/src/accounts/signing/message.js +6 -6
- package/dist/src/accounts/signing/passkeys.d.ts +8 -1
- package/dist/src/accounts/signing/passkeys.d.ts.map +1 -1
- package/dist/src/accounts/signing/passkeys.js +35 -0
- package/dist/src/accounts/signing/passkeys.test.js +15 -0
- package/dist/src/accounts/signing/typedData.d.ts.map +1 -1
- package/dist/src/accounts/signing/typedData.js +2 -2
- package/dist/src/accounts/startale.test.js +0 -4
- package/dist/src/accounts/utils.d.ts +2 -2
- package/dist/src/accounts/utils.d.ts.map +1 -1
- package/dist/src/accounts/walletClient.d.ts +7 -0
- package/dist/src/accounts/walletClient.d.ts.map +1 -0
- package/dist/src/accounts/walletClient.js +38 -0
- package/dist/src/actions/compact.d.ts +13 -0
- package/dist/src/actions/compact.d.ts.map +1 -0
- package/dist/src/actions/compact.js +210 -0
- package/dist/src/actions/ecdsa.d.ts +35 -0
- package/dist/src/actions/ecdsa.d.ts.map +1 -0
- package/dist/src/actions/ecdsa.js +114 -0
- package/dist/src/actions/ecdsa.test.d.ts +2 -0
- package/dist/src/actions/ecdsa.test.d.ts.map +1 -0
- package/dist/src/actions/ecdsa.test.js +99 -0
- package/dist/src/actions/index.d.ts +23 -166
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +25 -544
- package/dist/src/actions/mfa.d.ts +37 -0
- package/dist/src/actions/mfa.d.ts.map +1 -0
- package/dist/src/actions/mfa.js +133 -0
- package/dist/src/actions/passkeys.d.ts +37 -0
- package/dist/src/actions/passkeys.d.ts.map +1 -0
- package/dist/src/actions/passkeys.js +129 -0
- package/dist/src/actions/passkeys.test.d.ts +2 -0
- package/dist/src/actions/passkeys.test.d.ts.map +1 -0
- package/dist/src/actions/passkeys.test.js +54 -0
- package/dist/src/actions/recovery.d.ts +33 -0
- package/dist/src/actions/recovery.d.ts.map +1 -0
- package/dist/src/actions/recovery.js +193 -0
- package/dist/src/actions/recovery.test.d.ts +2 -0
- package/dist/src/actions/recovery.test.d.ts.map +1 -0
- package/dist/src/actions/recovery.test.js +168 -0
- package/dist/src/errors/index.d.ts +5 -0
- package/dist/src/errors/index.d.ts.map +1 -0
- package/dist/src/errors/index.js +35 -0
- package/dist/src/execution/compact.d.ts +24 -8
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +29 -103
- package/dist/src/execution/error.d.ts +2 -9
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +4 -13
- package/dist/src/execution/index.d.ts +33 -22
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +60 -41
- package/dist/src/execution/permit2.d.ts +148 -0
- package/dist/src/execution/permit2.d.ts.map +1 -0
- package/dist/src/execution/permit2.js +282 -0
- package/dist/src/execution/smart-session.d.ts +3 -3
- package/dist/src/execution/smart-session.d.ts.map +1 -1
- package/dist/src/execution/types.d.ts +35 -0
- package/dist/src/execution/types.d.ts.map +1 -0
- package/dist/src/execution/types.js +2 -0
- package/dist/src/execution/utils.d.ts +36 -28
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +248 -91
- package/dist/src/index.d.ts +37 -19
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +130 -66
- package/dist/src/modules/common.d.ts +10 -4
- package/dist/src/modules/common.d.ts.map +1 -1
- package/dist/src/modules/common.js +22 -1
- package/dist/src/modules/index.d.ts +3 -2
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +16 -13
- package/dist/src/modules/index.test.js +8 -11
- package/dist/src/modules/read.d.ts.map +1 -1
- package/dist/src/modules/read.js +4 -0
- package/dist/src/modules/validators/core.d.ts +5 -3
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +29 -10
- package/dist/src/modules/validators/core.test.js +4 -4
- package/dist/src/modules/validators/smart-sessions.test.js +0 -3
- package/dist/src/modules/validators/webauthn-contract.d.ts.map +1 -1
- package/dist/src/orchestrator/client.d.ts +2 -1
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +36 -14
- package/dist/src/orchestrator/consts.d.ts +1 -2
- package/dist/src/orchestrator/consts.d.ts.map +1 -1
- package/dist/src/orchestrator/consts.js +1 -3
- package/dist/src/orchestrator/registry.d.ts +2 -2
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +68 -30
- package/dist/src/orchestrator/registry.test.js +4 -4
- package/dist/src/orchestrator/types.d.ts +34 -25
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/types.d.ts +64 -9
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +73 -2
- package/dist/src/accounts/json-rpc/index.test.d.ts +0 -2
- package/dist/src/accounts/json-rpc/index.test.d.ts.map +0 -1
- package/dist/src/accounts/json-rpc/index.test.js +0 -16
- package/dist/src/accounts/json-rpc/providers.test.d.ts +0 -2
- package/dist/src/accounts/json-rpc/providers.test.d.ts.map +0 -1
- package/dist/src/accounts/json-rpc/providers.test.js +0 -15
- package/dist/src/actions/index.test.d.ts +0 -2
- package/dist/src/actions/index.test.d.ts.map +0 -1
- package/dist/src/actions/index.test.js +0 -302
|
@@ -1,37 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.WalletClientNoConnectedAccountError = exports.SmartSessionsNotEnabledError = exports.SigningNotSupportedForAccountError = exports.OwnersFieldRequiredError = exports.ModuleInstallationNotSupportedError = exports.FactoryArgsNotAvailableError = exports.ExistingEip7702AccountsNotSupportedError = exports.EoaSigningNotSupportedError = exports.EoaSigningMethodNotConfiguredError = exports.Eip7702NotSupportedForAccountError = exports.Eip7702AccountMustHaveEoaError = exports.AccountConfigurationNotSupportedError = exports.AccountError = exports.isAccountError = void 0;
|
|
4
4
|
exports.getModuleInstallationCalls = getModuleInstallationCalls;
|
|
5
5
|
exports.getModuleUninstallationCalls = getModuleUninstallationCalls;
|
|
6
6
|
exports.getAddress = getAddress;
|
|
7
|
+
exports.checkAddress = checkAddress;
|
|
7
8
|
exports.getAccountProvider = getAccountProvider;
|
|
8
9
|
exports.getInitCode = getInitCode;
|
|
9
10
|
exports.signEip7702InitData = signEip7702InitData;
|
|
10
11
|
exports.getEip7702InitCall = getEip7702InitCall;
|
|
12
|
+
exports.is7702 = is7702;
|
|
11
13
|
exports.isDeployed = isDeployed;
|
|
12
14
|
exports.deploy = deploy;
|
|
13
|
-
exports.
|
|
15
|
+
exports.setup = setup;
|
|
14
16
|
exports.toErc6492Signature = toErc6492Signature;
|
|
15
17
|
exports.getSmartAccount = getSmartAccount;
|
|
16
18
|
exports.getSmartSessionSmartAccount = getSmartSessionSmartAccount;
|
|
17
19
|
exports.getGuardianSmartAccount = getGuardianSmartAccount;
|
|
18
20
|
exports.getPackedSignature = getPackedSignature;
|
|
19
21
|
exports.getTypedDataPackedSignature = getTypedDataPackedSignature;
|
|
22
|
+
exports.deployStandaloneWithEoa = deployStandaloneWithEoa;
|
|
20
23
|
const viem_1 = require("viem");
|
|
21
24
|
const execution_1 = require("../execution");
|
|
22
25
|
const smart_session_1 = require("../execution/smart-session");
|
|
26
|
+
const modules_1 = require("../modules");
|
|
23
27
|
const validators_1 = require("../modules/validators");
|
|
24
28
|
const core_1 = require("../modules/validators/core");
|
|
25
29
|
const error_1 = require("./error");
|
|
30
|
+
Object.defineProperty(exports, "AccountConfigurationNotSupportedError", { enumerable: true, get: function () { return error_1.AccountConfigurationNotSupportedError; } });
|
|
26
31
|
Object.defineProperty(exports, "AccountError", { enumerable: true, get: function () { return error_1.AccountError; } });
|
|
27
32
|
Object.defineProperty(exports, "Eip7702AccountMustHaveEoaError", { enumerable: true, get: function () { return error_1.Eip7702AccountMustHaveEoaError; } });
|
|
28
33
|
Object.defineProperty(exports, "Eip7702NotSupportedForAccountError", { enumerable: true, get: function () { return error_1.Eip7702NotSupportedForAccountError; } });
|
|
34
|
+
Object.defineProperty(exports, "EoaSigningMethodNotConfiguredError", { enumerable: true, get: function () { return error_1.EoaSigningMethodNotConfiguredError; } });
|
|
35
|
+
Object.defineProperty(exports, "EoaSigningNotSupportedError", { enumerable: true, get: function () { return error_1.EoaSigningNotSupportedError; } });
|
|
29
36
|
Object.defineProperty(exports, "ExistingEip7702AccountsNotSupportedError", { enumerable: true, get: function () { return error_1.ExistingEip7702AccountsNotSupportedError; } });
|
|
30
37
|
Object.defineProperty(exports, "FactoryArgsNotAvailableError", { enumerable: true, get: function () { return error_1.FactoryArgsNotAvailableError; } });
|
|
31
38
|
Object.defineProperty(exports, "isAccountError", { enumerable: true, get: function () { return error_1.isAccountError; } });
|
|
39
|
+
Object.defineProperty(exports, "ModuleInstallationNotSupportedError", { enumerable: true, get: function () { return error_1.ModuleInstallationNotSupportedError; } });
|
|
40
|
+
Object.defineProperty(exports, "OwnersFieldRequiredError", { enumerable: true, get: function () { return error_1.OwnersFieldRequiredError; } });
|
|
32
41
|
Object.defineProperty(exports, "SigningNotSupportedForAccountError", { enumerable: true, get: function () { return error_1.SigningNotSupportedForAccountError; } });
|
|
33
|
-
Object.defineProperty(exports, "SignMessageNotSupportedByAccountError", { enumerable: true, get: function () { return error_1.SignMessageNotSupportedByAccountError; } });
|
|
34
42
|
Object.defineProperty(exports, "SmartSessionsNotEnabledError", { enumerable: true, get: function () { return error_1.SmartSessionsNotEnabledError; } });
|
|
43
|
+
Object.defineProperty(exports, "WalletClientNoConnectedAccountError", { enumerable: true, get: function () { return error_1.WalletClientNoConnectedAccountError; } });
|
|
35
44
|
const kernel_1 = require("./kernel");
|
|
36
45
|
const nexus_1 = require("./nexus");
|
|
37
46
|
const safe_1 = require("./safe");
|
|
@@ -55,12 +64,21 @@ function getDeployArgs(config) {
|
|
|
55
64
|
case 'startale': {
|
|
56
65
|
return (0, startale_1.getDeployArgs)(config);
|
|
57
66
|
}
|
|
67
|
+
case 'eoa': {
|
|
68
|
+
throw new Error('EOA accounts do not have deploy args');
|
|
69
|
+
}
|
|
58
70
|
}
|
|
59
71
|
}
|
|
60
72
|
function getInitCode(config) {
|
|
61
73
|
if (is7702(config)) {
|
|
62
74
|
return undefined;
|
|
63
75
|
}
|
|
76
|
+
else if (config.account?.type === 'eoa') {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
else if (config.initData) {
|
|
80
|
+
return config.initData;
|
|
81
|
+
}
|
|
64
82
|
else {
|
|
65
83
|
const { factory, factoryData } = getDeployArgs(config);
|
|
66
84
|
if (!factory || !factoryData) {
|
|
@@ -82,10 +100,16 @@ async function signEip7702InitData(config) {
|
|
|
82
100
|
case 'nexus': {
|
|
83
101
|
return await (0, nexus_1.signEip7702InitData)(config, eoa);
|
|
84
102
|
}
|
|
103
|
+
case 'eoa': {
|
|
104
|
+
throw new error_1.Eip7702NotSupportedForAccountError(account.type);
|
|
105
|
+
}
|
|
85
106
|
case 'safe':
|
|
86
107
|
case 'kernel':
|
|
87
108
|
case 'startale': {
|
|
88
|
-
throw new
|
|
109
|
+
throw new error_1.Eip7702NotSupportedForAccountError(account.type);
|
|
110
|
+
}
|
|
111
|
+
default: {
|
|
112
|
+
throw new error_1.Eip7702NotSupportedForAccountError(account.type);
|
|
89
113
|
}
|
|
90
114
|
}
|
|
91
115
|
}
|
|
@@ -98,7 +122,10 @@ async function getEip7702InitCall(config, signature) {
|
|
|
98
122
|
case 'safe':
|
|
99
123
|
case 'kernel':
|
|
100
124
|
case 'startale': {
|
|
101
|
-
throw new
|
|
125
|
+
throw new error_1.Eip7702NotSupportedForAccountError(account.type);
|
|
126
|
+
}
|
|
127
|
+
default: {
|
|
128
|
+
throw new error_1.Eip7702NotSupportedForAccountError(account.type);
|
|
102
129
|
}
|
|
103
130
|
}
|
|
104
131
|
}
|
|
@@ -119,6 +146,9 @@ function getModuleInstallationCalls(config, module) {
|
|
|
119
146
|
case 'startale': {
|
|
120
147
|
return [(0, startale_1.getInstallData)(module)];
|
|
121
148
|
}
|
|
149
|
+
case 'eoa': {
|
|
150
|
+
throw new error_1.ModuleInstallationNotSupportedError(account.type);
|
|
151
|
+
}
|
|
122
152
|
}
|
|
123
153
|
}
|
|
124
154
|
const installData = getInstallData();
|
|
@@ -179,12 +209,29 @@ function getAddress(config) {
|
|
|
179
209
|
case 'startale': {
|
|
180
210
|
return (0, startale_1.getAddress)(config);
|
|
181
211
|
}
|
|
212
|
+
case 'eoa': {
|
|
213
|
+
if (!config.eoa) {
|
|
214
|
+
throw new error_1.AccountError({
|
|
215
|
+
message: 'EOA account must have an EOA configured',
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
return config.eoa.address;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function checkAddress(config) {
|
|
223
|
+
if (!config.initData) {
|
|
224
|
+
return true;
|
|
182
225
|
}
|
|
226
|
+
return (config.initData.address.toLowerCase() === getAddress(config).toLowerCase());
|
|
183
227
|
}
|
|
184
228
|
// Signs and packs a signature to be EIP-1271 compatible
|
|
185
229
|
async function getPackedSignature(config, signers, chain, validator, hash, transformSignature = (signature) => signature) {
|
|
230
|
+
if (config.account?.type === 'eoa') {
|
|
231
|
+
throw new error_1.EoaSigningNotSupportedError('packed signatures');
|
|
232
|
+
}
|
|
186
233
|
signers = signers ?? (0, common_1.convertOwnerSetToSignerSet)(config.owners);
|
|
187
|
-
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash);
|
|
234
|
+
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash, false);
|
|
188
235
|
const account = getAccountProvider(config);
|
|
189
236
|
const address = getAddress(config);
|
|
190
237
|
switch (account.type) {
|
|
@@ -194,7 +241,8 @@ async function getPackedSignature(config, signers, chain, validator, hash, trans
|
|
|
194
241
|
}
|
|
195
242
|
case 'nexus': {
|
|
196
243
|
const signature = await signFn(hash);
|
|
197
|
-
|
|
244
|
+
const defaultValidatorAddress = (0, nexus_1.getDefaultValidatorAddress)(account.version);
|
|
245
|
+
return (0, nexus_1.packSignature)(signature, validator, transformSignature, defaultValidatorAddress);
|
|
198
246
|
}
|
|
199
247
|
case 'kernel': {
|
|
200
248
|
const signature = await signFn((0, kernel_1.wrapMessageHash)(hash, address));
|
|
@@ -204,10 +252,16 @@ async function getPackedSignature(config, signers, chain, validator, hash, trans
|
|
|
204
252
|
const signature = await signFn(hash);
|
|
205
253
|
return (0, startale_1.packSignature)(signature, validator, transformSignature);
|
|
206
254
|
}
|
|
255
|
+
default: {
|
|
256
|
+
throw new Error(`Unsupported account type: ${account.type}`);
|
|
257
|
+
}
|
|
207
258
|
}
|
|
208
259
|
}
|
|
209
260
|
// Signs and packs a signature to be EIP-1271 compatible
|
|
210
261
|
async function getTypedDataPackedSignature(config, signers, chain, validator, parameters, transformSignature = (signature) => signature) {
|
|
262
|
+
if (config.account?.type === 'eoa') {
|
|
263
|
+
throw new error_1.EoaSigningNotSupportedError('packed signatures');
|
|
264
|
+
}
|
|
211
265
|
const address = getAddress(config);
|
|
212
266
|
signers = signers ?? (0, common_1.convertOwnerSetToSignerSet)(config.owners);
|
|
213
267
|
const signFn = (parameters) => (0, typedData_1.sign)(signers, chain, address, parameters);
|
|
@@ -219,11 +273,12 @@ async function getTypedDataPackedSignature(config, signers, chain, validator, pa
|
|
|
219
273
|
}
|
|
220
274
|
case 'nexus': {
|
|
221
275
|
const signature = await signFn(parameters);
|
|
222
|
-
|
|
276
|
+
const defaultValidatorAddress = (0, nexus_1.getDefaultValidatorAddress)(account.version);
|
|
277
|
+
return (0, nexus_1.packSignature)(signature, validator, transformSignature, defaultValidatorAddress);
|
|
223
278
|
}
|
|
224
279
|
case 'kernel': {
|
|
225
280
|
const address = getAddress(config);
|
|
226
|
-
const signMessageFn = (hash) => (0, message_1.sign)(signers, chain, address, hash);
|
|
281
|
+
const signMessageFn = (hash) => (0, message_1.sign)(signers, chain, address, hash, false);
|
|
227
282
|
const signature = await signMessageFn((0, kernel_1.wrapMessageHash)((0, viem_1.hashTypedData)(parameters), address));
|
|
228
283
|
return (0, kernel_1.packSignature)(signature, validator, transformSignature);
|
|
229
284
|
}
|
|
@@ -231,9 +286,16 @@ async function getTypedDataPackedSignature(config, signers, chain, validator, pa
|
|
|
231
286
|
const signature = await signFn(parameters);
|
|
232
287
|
return (0, startale_1.packSignature)(signature, validator, transformSignature);
|
|
233
288
|
}
|
|
289
|
+
default: {
|
|
290
|
+
throw new Error(`Unsupported account type: ${account.type}`);
|
|
291
|
+
}
|
|
234
292
|
}
|
|
235
293
|
}
|
|
236
294
|
async function isDeployed(config, chain) {
|
|
295
|
+
const account = getAccountProvider(config);
|
|
296
|
+
if (account.type === 'eoa') {
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
237
299
|
const publicClient = (0, viem_1.createPublicClient)({
|
|
238
300
|
chain: chain,
|
|
239
301
|
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
@@ -252,10 +314,89 @@ async function isDeployed(config, chain) {
|
|
|
252
314
|
return (0, viem_1.size)(code) > 0;
|
|
253
315
|
}
|
|
254
316
|
async function deploy(config, chain, session) {
|
|
255
|
-
|
|
317
|
+
const account = getAccountProvider(config);
|
|
318
|
+
if (account.type === 'eoa') {
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
const deployed = await isDeployed(config, chain);
|
|
322
|
+
if (deployed) {
|
|
323
|
+
return false;
|
|
324
|
+
}
|
|
325
|
+
const asUserOp = config.initData && !config.initData.intentExecutorInstalled;
|
|
326
|
+
if (asUserOp) {
|
|
327
|
+
await deployWithBundler(chain, config);
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
await deployWithIntent(chain, config);
|
|
331
|
+
}
|
|
256
332
|
if (session) {
|
|
257
333
|
await (0, smart_session_1.enableSmartSession)(chain, config, session);
|
|
258
334
|
}
|
|
335
|
+
return true;
|
|
336
|
+
}
|
|
337
|
+
// Installs the missing modules
|
|
338
|
+
// Checks if the provided modules are already installed
|
|
339
|
+
// Useful for existing (already deployed) accounts
|
|
340
|
+
async function setup(config, chain) {
|
|
341
|
+
const account = getAccountProvider(config);
|
|
342
|
+
if (account.type === 'eoa') {
|
|
343
|
+
return false;
|
|
344
|
+
}
|
|
345
|
+
const modules = (0, modules_1.getSetup)(config);
|
|
346
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
347
|
+
chain,
|
|
348
|
+
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
349
|
+
});
|
|
350
|
+
const address = getAddress(config);
|
|
351
|
+
const allModules = [
|
|
352
|
+
...modules.validators,
|
|
353
|
+
...modules.executors,
|
|
354
|
+
...modules.fallbacks,
|
|
355
|
+
...modules.hooks,
|
|
356
|
+
];
|
|
357
|
+
// Check if the modules are already installed
|
|
358
|
+
const installedResults = await publicClient.multicall({
|
|
359
|
+
contracts: allModules.map((module) => ({
|
|
360
|
+
address: address,
|
|
361
|
+
abi: [
|
|
362
|
+
{
|
|
363
|
+
type: 'function',
|
|
364
|
+
name: 'isModuleInstalled',
|
|
365
|
+
inputs: [
|
|
366
|
+
{ type: 'uint256', name: 'moduleTypeId' },
|
|
367
|
+
{ type: 'address', name: 'module' },
|
|
368
|
+
{ type: 'bytes', name: 'additionalContext' },
|
|
369
|
+
],
|
|
370
|
+
outputs: [{ type: 'bool', name: 'isInstalled' }],
|
|
371
|
+
stateMutability: 'view',
|
|
372
|
+
},
|
|
373
|
+
],
|
|
374
|
+
functionName: 'isModuleInstalled',
|
|
375
|
+
args: [module.type, module.address, module.additionalContext],
|
|
376
|
+
})),
|
|
377
|
+
});
|
|
378
|
+
const isInstalled = installedResults.map((result) => result.result);
|
|
379
|
+
const modulesToInstall = allModules.filter((_, index) => !isInstalled[index]);
|
|
380
|
+
if (modulesToInstall.length === 0) {
|
|
381
|
+
// Nothing to install
|
|
382
|
+
return false;
|
|
383
|
+
}
|
|
384
|
+
const calls = [];
|
|
385
|
+
for (const module of modulesToInstall) {
|
|
386
|
+
calls.push(...getModuleInstallationCalls(config, module));
|
|
387
|
+
}
|
|
388
|
+
// Select the transaction infra layer based on the intent executor status
|
|
389
|
+
const intentExecutor = (0, modules_1.getIntentExecutor)(config);
|
|
390
|
+
const hasIntentExecutor = modulesToInstall.every((module) => module.address !== intentExecutor.address);
|
|
391
|
+
let result;
|
|
392
|
+
if (hasIntentExecutor) {
|
|
393
|
+
result = await (0, execution_1.sendTransactionInternal)(config, [chain], chain, calls, {});
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
result = await (0, execution_1.sendUserOperationInternal)(config, chain, calls);
|
|
397
|
+
}
|
|
398
|
+
await (0, execution_1.waitForExecution)(config, result, true);
|
|
399
|
+
return true;
|
|
259
400
|
}
|
|
260
401
|
async function deployWithIntent(chain, config) {
|
|
261
402
|
const publicClient = (0, viem_1.createPublicClient)({
|
|
@@ -279,10 +420,34 @@ async function deployWithIntent(chain, config) {
|
|
|
279
420
|
});
|
|
280
421
|
await (0, execution_1.waitForExecution)(config, result, true);
|
|
281
422
|
}
|
|
423
|
+
async function deployWithBundler(chain, config) {
|
|
424
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
425
|
+
chain,
|
|
426
|
+
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
427
|
+
});
|
|
428
|
+
const bundlerClient = (0, utils_1.getBundlerClient)(config, publicClient);
|
|
429
|
+
const smartAccount = await getSmartAccount(config, publicClient, chain);
|
|
430
|
+
const { factory, factoryData } = getDeployArgs(config);
|
|
431
|
+
const opHash = await bundlerClient.sendUserOperation({
|
|
432
|
+
account: smartAccount,
|
|
433
|
+
factory,
|
|
434
|
+
factoryData,
|
|
435
|
+
calls: [
|
|
436
|
+
{
|
|
437
|
+
to: viem_1.zeroAddress,
|
|
438
|
+
value: 0n,
|
|
439
|
+
data: '0x',
|
|
440
|
+
},
|
|
441
|
+
],
|
|
442
|
+
});
|
|
443
|
+
await bundlerClient.waitForUserOperationReceipt({
|
|
444
|
+
hash: opHash,
|
|
445
|
+
});
|
|
446
|
+
}
|
|
282
447
|
async function deployStandaloneWithEoa(chain, config, deployer) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
throw new
|
|
448
|
+
const account = getAccountProvider(config);
|
|
449
|
+
if (account.type === 'eoa') {
|
|
450
|
+
throw new Error('EOA accounts do not have deploy args');
|
|
286
451
|
}
|
|
287
452
|
const publicClient = (0, viem_1.createPublicClient)({
|
|
288
453
|
chain,
|
|
@@ -291,7 +456,6 @@ async function deployStandaloneWithEoa(chain, config, deployer) {
|
|
|
291
456
|
const address = getAddress(config);
|
|
292
457
|
const code = await publicClient.getCode({ address });
|
|
293
458
|
if (code && code !== '0x') {
|
|
294
|
-
// Already deployed
|
|
295
459
|
return;
|
|
296
460
|
}
|
|
297
461
|
const initCode = getInitCode(config);
|
|
@@ -332,17 +496,25 @@ async function toErc6492Signature(config, signature, chain) {
|
|
|
332
496
|
]);
|
|
333
497
|
}
|
|
334
498
|
async function getSmartAccount(config, client, chain) {
|
|
499
|
+
// EOA accounts don't need smart account functionality
|
|
500
|
+
if (config.account?.type === 'eoa') {
|
|
501
|
+
throw new Error('getSmartAccount is not supported for EOA accounts');
|
|
502
|
+
}
|
|
503
|
+
if (!config.owners) {
|
|
504
|
+
throw new error_1.OwnersFieldRequiredError();
|
|
505
|
+
}
|
|
335
506
|
const account = getAccountProvider(config);
|
|
336
507
|
const address = getAddress(config);
|
|
337
508
|
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
338
509
|
const signers = (0, common_1.convertOwnerSetToSignerSet)(config.owners);
|
|
339
|
-
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash);
|
|
510
|
+
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash, true);
|
|
340
511
|
switch (account.type) {
|
|
341
512
|
case 'safe': {
|
|
342
513
|
return (0, safe_1.getSmartAccount)(client, address, config.owners, ownerValidator.address, signFn);
|
|
343
514
|
}
|
|
344
515
|
case 'nexus': {
|
|
345
|
-
|
|
516
|
+
const defaultValidatorAddress = (0, nexus_1.getDefaultValidatorAddress)(account.version);
|
|
517
|
+
return (0, nexus_1.getSmartAccount)(client, address, config.owners, ownerValidator.address, signFn, defaultValidatorAddress);
|
|
346
518
|
}
|
|
347
519
|
case 'kernel': {
|
|
348
520
|
return (0, kernel_1.getSmartAccount)(client, address, config.owners, ownerValidator.address, signFn);
|
|
@@ -363,14 +535,15 @@ async function getSmartSessionSmartAccount(config, client, chain, session, enabl
|
|
|
363
535
|
session,
|
|
364
536
|
enableData: enableData || undefined,
|
|
365
537
|
};
|
|
366
|
-
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash);
|
|
538
|
+
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash, true);
|
|
367
539
|
const account = getAccountProvider(config);
|
|
368
540
|
switch (account.type) {
|
|
369
541
|
case 'safe': {
|
|
370
542
|
return (0, safe_1.getSessionSmartAccount)(client, address, session, smartSessionValidator.address, enableData, signFn);
|
|
371
543
|
}
|
|
372
544
|
case 'nexus': {
|
|
373
|
-
|
|
545
|
+
const defaultValidatorAddress = (0, nexus_1.getDefaultValidatorAddress)(account.version);
|
|
546
|
+
return (0, nexus_1.getSessionSmartAccount)(client, address, session, smartSessionValidator.address, enableData, signFn, defaultValidatorAddress);
|
|
374
547
|
}
|
|
375
548
|
case 'kernel': {
|
|
376
549
|
return (0, kernel_1.getSessionSmartAccount)(client, address, session, smartSessionValidator.address, enableData, signFn);
|
|
@@ -391,14 +564,15 @@ async function getGuardianSmartAccount(config, client, chain, guardians) {
|
|
|
391
564
|
type: 'guardians',
|
|
392
565
|
guardians: accounts,
|
|
393
566
|
};
|
|
394
|
-
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash);
|
|
567
|
+
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash, true);
|
|
395
568
|
const account = getAccountProvider(config);
|
|
396
569
|
switch (account.type) {
|
|
397
570
|
case 'safe': {
|
|
398
571
|
return (0, safe_1.getGuardianSmartAccount)(client, address, guardians, socialRecoveryValidator.address, signFn);
|
|
399
572
|
}
|
|
400
573
|
case 'nexus': {
|
|
401
|
-
|
|
574
|
+
const defaultValidatorAddress = (0, nexus_1.getDefaultValidatorAddress)(account.version);
|
|
575
|
+
return (0, nexus_1.getGuardianSmartAccount)(client, address, guardians, socialRecoveryValidator.address, signFn, defaultValidatorAddress);
|
|
402
576
|
}
|
|
403
577
|
case 'kernel': {
|
|
404
578
|
return (0, kernel_1.getGuardianSmartAccount)(client, address, guardians, socialRecoveryValidator.address, signFn);
|
|
@@ -409,7 +583,8 @@ async function getGuardianSmartAccount(config, client, chain, guardians) {
|
|
|
409
583
|
}
|
|
410
584
|
}
|
|
411
585
|
function is7702(config) {
|
|
412
|
-
|
|
586
|
+
const account = getAccountProvider(config);
|
|
587
|
+
return account.type !== 'eoa' && config.eoa !== undefined;
|
|
413
588
|
}
|
|
414
589
|
function getAccountProvider(config) {
|
|
415
590
|
if (config.account) {
|
|
@@ -12,9 +12,8 @@ const _1 = require(".");
|
|
|
12
12
|
accounts: [consts_1.accountA, consts_1.accountB],
|
|
13
13
|
threshold: 1,
|
|
14
14
|
},
|
|
15
|
-
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
16
15
|
});
|
|
17
|
-
(0, vitest_1.expect)(address).toEqual('
|
|
16
|
+
(0, vitest_1.expect)(address).toEqual('0x0681de31e060b384F0b08A3bAC99E9bDFf302474');
|
|
18
17
|
});
|
|
19
18
|
(0, vitest_1.test)('Safe, passkey owner with a session', () => {
|
|
20
19
|
const address = (0, _1.getAddress)({
|
|
@@ -22,9 +21,8 @@ const _1 = require(".");
|
|
|
22
21
|
type: 'passkey',
|
|
23
22
|
accounts: [consts_1.passkeyAccount],
|
|
24
23
|
},
|
|
25
|
-
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
26
24
|
});
|
|
27
|
-
(0, vitest_1.expect)(address).toEqual('
|
|
25
|
+
(0, vitest_1.expect)(address).toEqual('0x894b88C04B4DE6AbDdcE81E8bdc91927E37d6ceD');
|
|
28
26
|
});
|
|
29
27
|
});
|
|
30
28
|
(0, vitest_1.describe)('Sign', () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../../../accounts/json-rpc/providers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAExD,iBAAS,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../../../accounts/json-rpc/providers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAExD,iBAAS,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAetE;AAED,OAAO,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -1,14 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.getAlchemyUrl = getAlchemyUrl;
|
|
4
|
-
const
|
|
37
|
+
const sharedConfigs = __importStar(require("@rhinestone/shared-configs"));
|
|
5
38
|
function getAlchemyUrl(chainId, apiKey) {
|
|
6
|
-
const
|
|
7
|
-
|
|
39
|
+
const providers = sharedConfigs.providerRegistry ||
|
|
40
|
+
sharedConfigs.ProviderRegistry;
|
|
41
|
+
const urlTemplate = providers.Alchemy.url_template;
|
|
42
|
+
const mapping = providers.Alchemy
|
|
43
|
+
.chain_mapping;
|
|
44
|
+
const chainParam = mapping[chainId];
|
|
8
45
|
if (!chainParam) {
|
|
9
46
|
throw new Error(`Unsupported chain: ${chainId}`);
|
|
10
47
|
}
|
|
11
48
|
return urlTemplate
|
|
12
49
|
.replace('{{chain_param}}', chainParam)
|
|
13
|
-
.
|
|
50
|
+
.split('${ALCHEMY_API_KEY}')
|
|
51
|
+
.join(apiKey);
|
|
14
52
|
}
|
|
@@ -7,9 +7,9 @@ import { type ValidatorConfig } from './utils';
|
|
|
7
7
|
declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
8
8
|
factory: `0x${string}`;
|
|
9
9
|
factoryData: `0x${string}`;
|
|
10
|
-
salt: "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
11
10
|
implementation: `0x${string}`;
|
|
12
11
|
initializationCallData: `0x${string}`;
|
|
12
|
+
salt: `0x${string}`;
|
|
13
13
|
};
|
|
14
14
|
declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
|
|
15
15
|
declare function getInstallData(module: Module): Hex[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../../../accounts/kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EACR,KAAK,OAAO,
|
|
1
|
+
{"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../../../accounts/kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EACR,KAAK,OAAO,EASZ,KAAK,GAAG,EAER,KAAK,YAAY,EAMlB,MAAM,MAAM,CAAA;AACb,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAEhC,MAAM,0BAA0B,CAAA;AAGjC,OAAO,EAKL,KAAK,MAAM,EACZ,MAAM,mBAAmB,CAAA;AAQ1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAC7E,OAAO,KAAK,EAAE,QAAQ,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAE1E,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAgBhF,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;EA+ErD;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,iBASlD;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,EAAE,CAsE7C;AAED,iBAAe,aAAa,CAC1B,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,eAAe,EAC1B,kBAAkB,GAAE,CAAC,SAAS,EAAE,GAAG,KAAK,GAA8B,0BAYvE;AAED,iBAAS,eAAe,CAAC,WAAW,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,GAAG,GAAG,CAoBnE;AAED,iBAAe,eAAe,CAC5B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,QAAQ,EAChB,gBAAgB,EAAE,OAAO,EACzB,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,iEAYlC;AAED,iBAAe,sBAAsB,CACnC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,OAAO,EACzB,UAAU,EAAE,iBAAiB,GAAG,IAAI,EACpC,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,iEA0ClC;AAED,iBAAe,uBAAuB,CACpC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,QAAQ,EACnB,gBAAgB,EAAE,OAAO,EACzB,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,iEAclC;AA+ED,OAAO,EACL,cAAc,EACd,UAAU,EACV,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,aAAa,EACb,eAAe,GAChB,CAAA"}
|
|
@@ -13,13 +13,41 @@ const account_abstraction_1 = require("viem/account-abstraction");
|
|
|
13
13
|
const modules_1 = require("../modules");
|
|
14
14
|
const common_1 = require("../modules/common");
|
|
15
15
|
const validators_1 = require("../modules/validators");
|
|
16
|
+
const error_1 = require("./error");
|
|
16
17
|
const utils_1 = require("./utils");
|
|
17
18
|
const KERNEL_META_FACTORY_ADDRESS = '0xd703aae79538628d27099b8c4f621be4ccd142d5';
|
|
18
19
|
const KERNEL_IMPLEMENTATION_ADDRESS = '0xd6CEDDe84be40893d153Be9d467CD6aD37875b28';
|
|
19
|
-
const KERNEL_FACTORY_ADDRESS = '
|
|
20
|
+
const KERNEL_FACTORY_ADDRESS = '0x2577507b78c2008Ff367261CB6285d44ba5eF2E9';
|
|
20
21
|
const KERNEL_BYTECODE = '0x603d3d8160223d3973d6cedde84be40893d153be9d467cd6ad37875b2860095155f3363d3d373d3d363d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc545af43d6000803e6038573d6000fd5b3d6000f3';
|
|
21
22
|
const KERNEL_VERSION = '0.3.3';
|
|
22
23
|
function getDeployArgs(config) {
|
|
24
|
+
if (config.initData) {
|
|
25
|
+
const factoryData = (0, viem_1.decodeFunctionData)({
|
|
26
|
+
abi: (0, viem_1.parseAbi)([
|
|
27
|
+
'function deployWithFactory(address factory,bytes createData,bytes32 salt)',
|
|
28
|
+
]),
|
|
29
|
+
data: config.initData.factoryData,
|
|
30
|
+
});
|
|
31
|
+
if (factoryData.functionName !== 'deployWithFactory') {
|
|
32
|
+
throw new error_1.AccountConfigurationNotSupportedError('Invalid factory data', 'kernel');
|
|
33
|
+
}
|
|
34
|
+
const factory = factoryData.args[0];
|
|
35
|
+
const createData = factoryData.args[1];
|
|
36
|
+
const salt = factoryData.args[2];
|
|
37
|
+
const implementation = factory === KERNEL_FACTORY_ADDRESS
|
|
38
|
+
? KERNEL_IMPLEMENTATION_ADDRESS
|
|
39
|
+
: viem_1.zeroAddress;
|
|
40
|
+
if (implementation === viem_1.zeroAddress) {
|
|
41
|
+
throw new error_1.AccountConfigurationNotSupportedError('Unsupported Kernel implementation', 'kernel');
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
factory: config.initData.factory,
|
|
45
|
+
factoryData: config.initData.factoryData,
|
|
46
|
+
implementation,
|
|
47
|
+
initializationCallData: createData,
|
|
48
|
+
salt,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
23
51
|
const salt = viem_1.zeroHash;
|
|
24
52
|
const moduleSetup = (0, modules_1.getSetup)(config);
|
|
25
53
|
const rootValidator = (0, viem_1.concat)(['0x01', moduleSetup.validators[0].address]);
|