@charterlabs/rhinestone-sdk 0.2.7-dev.3 → 0.2.8
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/README.md +46 -8
- 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 +31 -20
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +231 -25
- package/dist/src/accounts/index.test.js +2 -4
- package/dist/src/accounts/json-rpc/index.d.ts +5 -0
- package/dist/src/accounts/json-rpc/index.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/index.js +16 -0
- package/dist/src/accounts/json-rpc/providers.d.ts +4 -0
- package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/providers.js +52 -0
- 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/passport.d.ts +12 -0
- package/dist/src/accounts/passport.d.ts.map +1 -0
- package/dist/src/accounts/passport.js +173 -0
- 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 +4 -4
- package/dist/src/accounts/utils.d.ts.map +1 -1
- package/dist/src/accounts/utils.js +3 -40
- 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/actions/smart-sessions.d.ts +23 -0
- package/dist/src/actions/smart-sessions.d.ts.map +1 -0
- package/dist/src/actions/{smart-session.js → smart-sessions.js} +13 -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 +50 -0
- package/dist/src/execution/compact.d.ts +25 -9
- 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 +6 -6
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +13 -13
- package/dist/src/execution/index.d.ts +34 -22
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +115 -46
- package/dist/src/execution/multiChainOps.d.ts +40 -0
- package/dist/src/execution/multiChainOps.d.ts.map +1 -0
- package/dist/src/execution/multiChainOps.js +39 -0
- 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 +291 -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/smart-session.js +3 -3
- package/dist/src/execution/types.d.ts +36 -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 +43 -28
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +269 -99
- package/dist/src/index.d.ts +38 -19
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +121 -69
- 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 +9 -12
- package/dist/src/modules/read.d.ts.map +1 -1
- package/dist/src/modules/read.js +5 -1
- 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.d.ts +4 -4
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
- package/dist/src/modules/validators/smart-sessions.js +10 -72
- package/dist/src/modules/validators/smart-sessions.test.js +4 -8
- package/dist/src/modules/validators/webauthn-contract.d.ts.map +1 -1
- package/dist/src/orchestrator/client.d.ts +4 -2
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +230 -162
- 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/error.d.ts +111 -1
- package/dist/src/orchestrator/error.d.ts.map +1 -1
- package/dist/src/orchestrator/error.js +128 -1
- package/dist/src/orchestrator/index.d.ts +4 -4
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +16 -1
- package/dist/src/orchestrator/registry.d.ts +3 -25
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +82 -46
- package/dist/src/orchestrator/registry.test.js +7 -7
- package/dist/src/orchestrator/types.d.ts +53 -43
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/types.d.ts +74 -9
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/index.d.ts +3 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/utils/index.js +5 -0
- package/package.json +73 -2
- 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
- package/dist/src/actions/smart-session.d.ts +0 -11
- package/dist/src/actions/smart-session.d.ts.map +0 -1
- package/dist/src/orchestrator/registry.json +0 -365
|
@@ -1,39 +1,49 @@
|
|
|
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");
|
|
46
|
+
const passport_1 = require("./passport");
|
|
37
47
|
const safe_1 = require("./safe");
|
|
38
48
|
const common_1 = require("./signing/common");
|
|
39
49
|
const message_1 = require("./signing/message");
|
|
@@ -55,12 +65,32 @@ function getDeployArgs(config) {
|
|
|
55
65
|
case 'startale': {
|
|
56
66
|
return (0, startale_1.getDeployArgs)(config);
|
|
57
67
|
}
|
|
68
|
+
case 'passport': {
|
|
69
|
+
// Mocked data; will be overridden by the actual deploy args
|
|
70
|
+
return {
|
|
71
|
+
factory: viem_1.zeroAddress,
|
|
72
|
+
factoryData: viem_1.zeroHash,
|
|
73
|
+
salt: viem_1.zeroHash,
|
|
74
|
+
implementation: viem_1.zeroAddress,
|
|
75
|
+
initializationCallData: '0x',
|
|
76
|
+
initData: '0x',
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
case 'eoa': {
|
|
80
|
+
throw new Error('EOA accounts do not have deploy args');
|
|
81
|
+
}
|
|
58
82
|
}
|
|
59
83
|
}
|
|
60
84
|
function getInitCode(config) {
|
|
61
85
|
if (is7702(config)) {
|
|
62
86
|
return undefined;
|
|
63
87
|
}
|
|
88
|
+
else if (config.account?.type === 'eoa') {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
else if (config.initData) {
|
|
92
|
+
return config.initData;
|
|
93
|
+
}
|
|
64
94
|
else {
|
|
65
95
|
const { factory, factoryData } = getDeployArgs(config);
|
|
66
96
|
if (!factory || !factoryData) {
|
|
@@ -82,10 +112,16 @@ async function signEip7702InitData(config) {
|
|
|
82
112
|
case 'nexus': {
|
|
83
113
|
return await (0, nexus_1.signEip7702InitData)(config, eoa);
|
|
84
114
|
}
|
|
115
|
+
case 'eoa': {
|
|
116
|
+
throw new error_1.Eip7702NotSupportedForAccountError(account.type);
|
|
117
|
+
}
|
|
85
118
|
case 'safe':
|
|
86
119
|
case 'kernel':
|
|
87
120
|
case 'startale': {
|
|
88
|
-
throw new
|
|
121
|
+
throw new error_1.Eip7702NotSupportedForAccountError(account.type);
|
|
122
|
+
}
|
|
123
|
+
default: {
|
|
124
|
+
throw new error_1.Eip7702NotSupportedForAccountError(account.type);
|
|
89
125
|
}
|
|
90
126
|
}
|
|
91
127
|
}
|
|
@@ -98,7 +134,10 @@ async function getEip7702InitCall(config, signature) {
|
|
|
98
134
|
case 'safe':
|
|
99
135
|
case 'kernel':
|
|
100
136
|
case 'startale': {
|
|
101
|
-
throw new
|
|
137
|
+
throw new error_1.Eip7702NotSupportedForAccountError(account.type);
|
|
138
|
+
}
|
|
139
|
+
default: {
|
|
140
|
+
throw new error_1.Eip7702NotSupportedForAccountError(account.type);
|
|
102
141
|
}
|
|
103
142
|
}
|
|
104
143
|
}
|
|
@@ -119,6 +158,12 @@ function getModuleInstallationCalls(config, module) {
|
|
|
119
158
|
case 'startale': {
|
|
120
159
|
return [(0, startale_1.getInstallData)(module)];
|
|
121
160
|
}
|
|
161
|
+
case 'passport': {
|
|
162
|
+
return [(0, passport_1.getInstallData)(module)];
|
|
163
|
+
}
|
|
164
|
+
case 'eoa': {
|
|
165
|
+
throw new error_1.ModuleInstallationNotSupportedError(account.type);
|
|
166
|
+
}
|
|
122
167
|
}
|
|
123
168
|
}
|
|
124
169
|
const installData = getInstallData();
|
|
@@ -179,12 +224,32 @@ function getAddress(config) {
|
|
|
179
224
|
case 'startale': {
|
|
180
225
|
return (0, startale_1.getAddress)(config);
|
|
181
226
|
}
|
|
227
|
+
case 'passport': {
|
|
228
|
+
return (0, passport_1.getAddress)(config);
|
|
229
|
+
}
|
|
230
|
+
case 'eoa': {
|
|
231
|
+
if (!config.eoa) {
|
|
232
|
+
throw new error_1.AccountError({
|
|
233
|
+
message: 'EOA account must have an EOA configured',
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
return config.eoa.address;
|
|
237
|
+
}
|
|
182
238
|
}
|
|
183
239
|
}
|
|
240
|
+
function checkAddress(config) {
|
|
241
|
+
if (!config.initData) {
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
return (config.initData.address.toLowerCase() === getAddress(config).toLowerCase());
|
|
245
|
+
}
|
|
184
246
|
// Signs and packs a signature to be EIP-1271 compatible
|
|
185
247
|
async function getPackedSignature(config, signers, chain, validator, hash, transformSignature = (signature) => signature) {
|
|
248
|
+
if (config.account?.type === 'eoa') {
|
|
249
|
+
throw new error_1.EoaSigningNotSupportedError('packed signatures');
|
|
250
|
+
}
|
|
186
251
|
signers = signers ?? (0, common_1.convertOwnerSetToSignerSet)(config.owners);
|
|
187
|
-
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash);
|
|
252
|
+
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash, false);
|
|
188
253
|
const account = getAccountProvider(config);
|
|
189
254
|
const address = getAddress(config);
|
|
190
255
|
switch (account.type) {
|
|
@@ -194,7 +259,12 @@ async function getPackedSignature(config, signers, chain, validator, hash, trans
|
|
|
194
259
|
}
|
|
195
260
|
case 'nexus': {
|
|
196
261
|
const signature = await signFn(hash);
|
|
197
|
-
|
|
262
|
+
const defaultValidatorAddress = (0, nexus_1.getDefaultValidatorAddress)(account.version);
|
|
263
|
+
return (0, nexus_1.packSignature)(signature, validator, transformSignature, defaultValidatorAddress);
|
|
264
|
+
}
|
|
265
|
+
case 'passport': {
|
|
266
|
+
const signature = await signFn(hash);
|
|
267
|
+
return (0, passport_1.packSignature)(signature, validator, transformSignature);
|
|
198
268
|
}
|
|
199
269
|
case 'kernel': {
|
|
200
270
|
const signature = await signFn((0, kernel_1.wrapMessageHash)(hash, address));
|
|
@@ -204,10 +274,16 @@ async function getPackedSignature(config, signers, chain, validator, hash, trans
|
|
|
204
274
|
const signature = await signFn(hash);
|
|
205
275
|
return (0, startale_1.packSignature)(signature, validator, transformSignature);
|
|
206
276
|
}
|
|
277
|
+
default: {
|
|
278
|
+
throw new Error(`Unsupported account type: ${account.type}`);
|
|
279
|
+
}
|
|
207
280
|
}
|
|
208
281
|
}
|
|
209
282
|
// Signs and packs a signature to be EIP-1271 compatible
|
|
210
283
|
async function getTypedDataPackedSignature(config, signers, chain, validator, parameters, transformSignature = (signature) => signature) {
|
|
284
|
+
if (config.account?.type === 'eoa') {
|
|
285
|
+
throw new error_1.EoaSigningNotSupportedError('packed signatures');
|
|
286
|
+
}
|
|
211
287
|
const address = getAddress(config);
|
|
212
288
|
signers = signers ?? (0, common_1.convertOwnerSetToSignerSet)(config.owners);
|
|
213
289
|
const signFn = (parameters) => (0, typedData_1.sign)(signers, chain, address, parameters);
|
|
@@ -219,11 +295,16 @@ async function getTypedDataPackedSignature(config, signers, chain, validator, pa
|
|
|
219
295
|
}
|
|
220
296
|
case 'nexus': {
|
|
221
297
|
const signature = await signFn(parameters);
|
|
222
|
-
|
|
298
|
+
const defaultValidatorAddress = (0, nexus_1.getDefaultValidatorAddress)(account.version);
|
|
299
|
+
return (0, nexus_1.packSignature)(signature, validator, transformSignature, defaultValidatorAddress);
|
|
300
|
+
}
|
|
301
|
+
case 'passport': {
|
|
302
|
+
const signature = await signFn(parameters);
|
|
303
|
+
return (0, passport_1.packSignature)(signature, validator, transformSignature);
|
|
223
304
|
}
|
|
224
305
|
case 'kernel': {
|
|
225
306
|
const address = getAddress(config);
|
|
226
|
-
const signMessageFn = (hash) => (0, message_1.sign)(signers, chain, address, hash);
|
|
307
|
+
const signMessageFn = (hash) => (0, message_1.sign)(signers, chain, address, hash, false);
|
|
227
308
|
const signature = await signMessageFn((0, kernel_1.wrapMessageHash)((0, viem_1.hashTypedData)(parameters), address));
|
|
228
309
|
return (0, kernel_1.packSignature)(signature, validator, transformSignature);
|
|
229
310
|
}
|
|
@@ -231,9 +312,16 @@ async function getTypedDataPackedSignature(config, signers, chain, validator, pa
|
|
|
231
312
|
const signature = await signFn(parameters);
|
|
232
313
|
return (0, startale_1.packSignature)(signature, validator, transformSignature);
|
|
233
314
|
}
|
|
315
|
+
default: {
|
|
316
|
+
throw new Error(`Unsupported account type: ${account.type}`);
|
|
317
|
+
}
|
|
234
318
|
}
|
|
235
319
|
}
|
|
236
320
|
async function isDeployed(config, chain) {
|
|
321
|
+
const account = getAccountProvider(config);
|
|
322
|
+
if (account.type === 'eoa') {
|
|
323
|
+
return true;
|
|
324
|
+
}
|
|
237
325
|
const publicClient = (0, viem_1.createPublicClient)({
|
|
238
326
|
chain: chain,
|
|
239
327
|
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
@@ -251,13 +339,92 @@ async function isDeployed(config, chain) {
|
|
|
251
339
|
}
|
|
252
340
|
return (0, viem_1.size)(code) > 0;
|
|
253
341
|
}
|
|
254
|
-
async function deploy(config, chain,
|
|
255
|
-
|
|
256
|
-
if (
|
|
257
|
-
|
|
342
|
+
async function deploy(config, chain, params) {
|
|
343
|
+
const account = getAccountProvider(config);
|
|
344
|
+
if (account.type === 'eoa') {
|
|
345
|
+
return false;
|
|
258
346
|
}
|
|
347
|
+
const deployed = await isDeployed(config, chain);
|
|
348
|
+
if (deployed) {
|
|
349
|
+
return false;
|
|
350
|
+
}
|
|
351
|
+
const asUserOp = config.initData && !config.initData.intentExecutorInstalled;
|
|
352
|
+
if (asUserOp) {
|
|
353
|
+
await deployWithBundler(chain, config);
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
await deployWithIntent(chain, config, params?.sponsored ?? false);
|
|
357
|
+
}
|
|
358
|
+
if (params?.session) {
|
|
359
|
+
await (0, smart_session_1.enableSmartSession)(chain, config, params.session);
|
|
360
|
+
}
|
|
361
|
+
return true;
|
|
259
362
|
}
|
|
260
|
-
|
|
363
|
+
// Installs the missing modules
|
|
364
|
+
// Checks if the provided modules are already installed
|
|
365
|
+
// Useful for existing (already deployed) accounts
|
|
366
|
+
async function setup(config, chain) {
|
|
367
|
+
const account = getAccountProvider(config);
|
|
368
|
+
if (account.type === 'eoa') {
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
const modules = (0, modules_1.getSetup)(config);
|
|
372
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
373
|
+
chain,
|
|
374
|
+
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
375
|
+
});
|
|
376
|
+
const address = getAddress(config);
|
|
377
|
+
const allModules = [
|
|
378
|
+
...modules.validators,
|
|
379
|
+
...modules.executors,
|
|
380
|
+
...modules.fallbacks,
|
|
381
|
+
...modules.hooks,
|
|
382
|
+
];
|
|
383
|
+
// Check if the modules are already installed
|
|
384
|
+
const installedResults = await publicClient.multicall({
|
|
385
|
+
contracts: allModules.map((module) => ({
|
|
386
|
+
address: address,
|
|
387
|
+
abi: [
|
|
388
|
+
{
|
|
389
|
+
type: 'function',
|
|
390
|
+
name: 'isModuleInstalled',
|
|
391
|
+
inputs: [
|
|
392
|
+
{ type: 'uint256', name: 'moduleTypeId' },
|
|
393
|
+
{ type: 'address', name: 'module' },
|
|
394
|
+
{ type: 'bytes', name: 'additionalContext' },
|
|
395
|
+
],
|
|
396
|
+
outputs: [{ type: 'bool', name: 'isInstalled' }],
|
|
397
|
+
stateMutability: 'view',
|
|
398
|
+
},
|
|
399
|
+
],
|
|
400
|
+
functionName: 'isModuleInstalled',
|
|
401
|
+
args: [module.type, module.address, module.additionalContext],
|
|
402
|
+
})),
|
|
403
|
+
});
|
|
404
|
+
const isInstalled = installedResults.map((result) => result.result);
|
|
405
|
+
const modulesToInstall = allModules.filter((_, index) => !isInstalled[index]);
|
|
406
|
+
if (modulesToInstall.length === 0) {
|
|
407
|
+
// Nothing to install
|
|
408
|
+
return false;
|
|
409
|
+
}
|
|
410
|
+
const calls = [];
|
|
411
|
+
for (const module of modulesToInstall) {
|
|
412
|
+
calls.push(...getModuleInstallationCalls(config, module));
|
|
413
|
+
}
|
|
414
|
+
// Select the transaction infra layer based on the intent executor status
|
|
415
|
+
const intentExecutor = (0, modules_1.getIntentExecutor)(config);
|
|
416
|
+
const hasIntentExecutor = modulesToInstall.every((module) => module.address !== intentExecutor.address);
|
|
417
|
+
let result;
|
|
418
|
+
if (hasIntentExecutor) {
|
|
419
|
+
result = await (0, execution_1.sendTransactionInternal)(config, [chain], chain, calls, {});
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
result = await (0, execution_1.sendUserOperationInternal)(config, chain, calls);
|
|
423
|
+
}
|
|
424
|
+
await (0, execution_1.waitForExecution)(config, result, true);
|
|
425
|
+
return true;
|
|
426
|
+
}
|
|
427
|
+
async function deployWithIntent(chain, config, sponsored) {
|
|
261
428
|
const publicClient = (0, viem_1.createPublicClient)({
|
|
262
429
|
chain,
|
|
263
430
|
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
@@ -269,6 +436,7 @@ async function deployWithIntent(chain, config) {
|
|
|
269
436
|
return;
|
|
270
437
|
}
|
|
271
438
|
const result = await (0, execution_1.sendTransaction)(config, {
|
|
439
|
+
sourceChains: [chain],
|
|
272
440
|
targetChain: chain,
|
|
273
441
|
calls: [
|
|
274
442
|
{
|
|
@@ -276,13 +444,38 @@ async function deployWithIntent(chain, config) {
|
|
|
276
444
|
data: '0x',
|
|
277
445
|
},
|
|
278
446
|
],
|
|
447
|
+
sponsored,
|
|
279
448
|
});
|
|
280
449
|
await (0, execution_1.waitForExecution)(config, result, true);
|
|
281
450
|
}
|
|
451
|
+
async function deployWithBundler(chain, config) {
|
|
452
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
453
|
+
chain,
|
|
454
|
+
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
455
|
+
});
|
|
456
|
+
const bundlerClient = (0, utils_1.getBundlerClient)(config, publicClient);
|
|
457
|
+
const smartAccount = await getSmartAccount(config, publicClient, chain);
|
|
458
|
+
const { factory, factoryData } = getDeployArgs(config);
|
|
459
|
+
const opHash = await bundlerClient.sendUserOperation({
|
|
460
|
+
account: smartAccount,
|
|
461
|
+
factory,
|
|
462
|
+
factoryData,
|
|
463
|
+
calls: [
|
|
464
|
+
{
|
|
465
|
+
to: viem_1.zeroAddress,
|
|
466
|
+
value: 0n,
|
|
467
|
+
data: '0x',
|
|
468
|
+
},
|
|
469
|
+
],
|
|
470
|
+
});
|
|
471
|
+
await bundlerClient.waitForUserOperationReceipt({
|
|
472
|
+
hash: opHash,
|
|
473
|
+
});
|
|
474
|
+
}
|
|
282
475
|
async function deployStandaloneWithEoa(chain, config, deployer) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
throw new
|
|
476
|
+
const account = getAccountProvider(config);
|
|
477
|
+
if (account.type === 'eoa') {
|
|
478
|
+
throw new Error('EOA accounts do not have deploy args');
|
|
286
479
|
}
|
|
287
480
|
const publicClient = (0, viem_1.createPublicClient)({
|
|
288
481
|
chain,
|
|
@@ -291,7 +484,6 @@ async function deployStandaloneWithEoa(chain, config, deployer) {
|
|
|
291
484
|
const address = getAddress(config);
|
|
292
485
|
const code = await publicClient.getCode({ address });
|
|
293
486
|
if (code && code !== '0x') {
|
|
294
|
-
// Already deployed
|
|
295
487
|
return;
|
|
296
488
|
}
|
|
297
489
|
const initCode = getInitCode(config);
|
|
@@ -332,17 +524,25 @@ async function toErc6492Signature(config, signature, chain) {
|
|
|
332
524
|
]);
|
|
333
525
|
}
|
|
334
526
|
async function getSmartAccount(config, client, chain) {
|
|
527
|
+
// EOA accounts don't need smart account functionality
|
|
528
|
+
if (config.account?.type === 'eoa') {
|
|
529
|
+
throw new Error('getSmartAccount is not supported for EOA accounts');
|
|
530
|
+
}
|
|
531
|
+
if (!config.owners) {
|
|
532
|
+
throw new error_1.OwnersFieldRequiredError();
|
|
533
|
+
}
|
|
335
534
|
const account = getAccountProvider(config);
|
|
336
535
|
const address = getAddress(config);
|
|
337
536
|
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
338
537
|
const signers = (0, common_1.convertOwnerSetToSignerSet)(config.owners);
|
|
339
|
-
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash);
|
|
538
|
+
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash, true);
|
|
340
539
|
switch (account.type) {
|
|
341
540
|
case 'safe': {
|
|
342
541
|
return (0, safe_1.getSmartAccount)(client, address, config.owners, ownerValidator.address, signFn);
|
|
343
542
|
}
|
|
344
543
|
case 'nexus': {
|
|
345
|
-
|
|
544
|
+
const defaultValidatorAddress = (0, nexus_1.getDefaultValidatorAddress)(account.version);
|
|
545
|
+
return (0, nexus_1.getSmartAccount)(client, address, config.owners, ownerValidator.address, signFn, defaultValidatorAddress);
|
|
346
546
|
}
|
|
347
547
|
case 'kernel': {
|
|
348
548
|
return (0, kernel_1.getSmartAccount)(client, address, config.owners, ownerValidator.address, signFn);
|
|
@@ -363,18 +563,22 @@ async function getSmartSessionSmartAccount(config, client, chain, session, enabl
|
|
|
363
563
|
session,
|
|
364
564
|
enableData: enableData || undefined,
|
|
365
565
|
};
|
|
366
|
-
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash);
|
|
566
|
+
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash, true);
|
|
367
567
|
const account = getAccountProvider(config);
|
|
368
568
|
switch (account.type) {
|
|
369
569
|
case 'safe': {
|
|
370
570
|
return (0, safe_1.getSessionSmartAccount)(client, address, session, smartSessionValidator.address, enableData, signFn);
|
|
371
571
|
}
|
|
372
572
|
case 'nexus': {
|
|
373
|
-
|
|
573
|
+
const defaultValidatorAddress = (0, nexus_1.getDefaultValidatorAddress)(account.version);
|
|
574
|
+
return (0, nexus_1.getSessionSmartAccount)(client, address, session, smartSessionValidator.address, enableData, signFn, defaultValidatorAddress);
|
|
374
575
|
}
|
|
375
576
|
case 'kernel': {
|
|
376
577
|
return (0, kernel_1.getSessionSmartAccount)(client, address, session, smartSessionValidator.address, enableData, signFn);
|
|
377
578
|
}
|
|
579
|
+
case 'passport': {
|
|
580
|
+
return (0, passport_1.getSessionSmartAccount)(client, address, session, smartSessionValidator.address, enableData, signFn);
|
|
581
|
+
}
|
|
378
582
|
case 'startale': {
|
|
379
583
|
return (0, startale_1.getSessionSmartAccount)(client, address, session, smartSessionValidator.address, enableData, signFn);
|
|
380
584
|
}
|
|
@@ -391,14 +595,15 @@ async function getGuardianSmartAccount(config, client, chain, guardians) {
|
|
|
391
595
|
type: 'guardians',
|
|
392
596
|
guardians: accounts,
|
|
393
597
|
};
|
|
394
|
-
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash);
|
|
598
|
+
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash, true);
|
|
395
599
|
const account = getAccountProvider(config);
|
|
396
600
|
switch (account.type) {
|
|
397
601
|
case 'safe': {
|
|
398
602
|
return (0, safe_1.getGuardianSmartAccount)(client, address, guardians, socialRecoveryValidator.address, signFn);
|
|
399
603
|
}
|
|
400
604
|
case 'nexus': {
|
|
401
|
-
|
|
605
|
+
const defaultValidatorAddress = (0, nexus_1.getDefaultValidatorAddress)(account.version);
|
|
606
|
+
return (0, nexus_1.getGuardianSmartAccount)(client, address, guardians, socialRecoveryValidator.address, signFn, defaultValidatorAddress);
|
|
402
607
|
}
|
|
403
608
|
case 'kernel': {
|
|
404
609
|
return (0, kernel_1.getGuardianSmartAccount)(client, address, guardians, socialRecoveryValidator.address, signFn);
|
|
@@ -409,7 +614,8 @@ async function getGuardianSmartAccount(config, client, chain, guardians) {
|
|
|
409
614
|
}
|
|
410
615
|
}
|
|
411
616
|
function is7702(config) {
|
|
412
|
-
|
|
617
|
+
const account = getAccountProvider(config);
|
|
618
|
+
return account.type !== 'eoa' && config.eoa !== undefined;
|
|
413
619
|
}
|
|
414
620
|
function getAccountProvider(config) {
|
|
415
621
|
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', () => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../accounts/json-rpc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAQ,KAAK,SAAS,EAAE,MAAM,MAAM,CAAA;AAEvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAGjD,iBAAS,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,SAAS,CAc3E;AAED,OAAO,EAAE,eAAe,EAAE,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTransport = createTransport;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const providers_1 = require("./providers");
|
|
6
|
+
function createTransport(chain, provider) {
|
|
7
|
+
if (!provider) {
|
|
8
|
+
return (0, viem_1.http)();
|
|
9
|
+
}
|
|
10
|
+
switch (provider.type) {
|
|
11
|
+
case 'alchemy': {
|
|
12
|
+
const alchemyUrl = (0, providers_1.getAlchemyUrl)(chain.id, provider.apiKey);
|
|
13
|
+
return (0, viem_1.http)(alchemyUrl);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +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,CAetE;AAED,OAAO,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getAlchemyUrl = getAlchemyUrl;
|
|
37
|
+
const sharedConfigs = __importStar(require("@rhinestone/shared-configs"));
|
|
38
|
+
function getAlchemyUrl(chainId, apiKey) {
|
|
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];
|
|
45
|
+
if (!chainParam) {
|
|
46
|
+
throw new Error(`Unsupported chain: ${chainId}`);
|
|
47
|
+
}
|
|
48
|
+
return urlTemplate
|
|
49
|
+
.replace('{{chain_param}}', chainParam)
|
|
50
|
+
.split('${ALCHEMY_API_KEY}')
|
|
51
|
+
.join(apiKey);
|
|
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]);
|