@charterlabs/rhinestone-sdk 0.1.13 → 0.2.0
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 +181 -74
- package/dist/src/accounts/index.d.ts +8 -7
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +65 -210
- package/dist/src/accounts/index.test.js +2 -3
- package/dist/src/accounts/kernel.d.ts +3 -2
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +3 -5
- package/dist/src/accounts/kernel.test.js +5 -12
- package/dist/src/accounts/nexus.d.ts +2 -2
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +17 -17
- package/dist/src/accounts/nexus.test.js +11 -14
- package/dist/src/accounts/safe.d.ts +2 -2
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +3 -5
- package/dist/src/accounts/safe.test.js +4 -7
- package/dist/src/accounts/signing/common.d.ts +23 -0
- package/dist/src/accounts/signing/common.d.ts.map +1 -0
- package/dist/src/accounts/signing/common.js +113 -0
- package/dist/src/accounts/signing/message.d.ts +5 -0
- package/dist/src/accounts/signing/message.d.ts.map +1 -0
- package/dist/src/accounts/signing/message.js +51 -0
- package/dist/src/accounts/signing/typedData.d.ts +5 -0
- package/dist/src/accounts/signing/typedData.d.ts.map +1 -0
- package/dist/src/accounts/signing/typedData.js +39 -0
- package/dist/src/accounts/startale.d.ts +2 -2
- package/dist/src/accounts/startale.d.ts.map +1 -1
- package/dist/src/accounts/startale.js +3 -3
- package/dist/src/accounts/startale.test.js +4 -7
- package/dist/src/actions/index.d.ts +84 -0
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +92 -0
- package/dist/src/actions/index.test.js +15 -15
- package/dist/src/actions/smart-session.d.ts +6 -0
- package/dist/src/actions/smart-session.d.ts.map +1 -1
- package/dist/src/actions/smart-session.js +6 -0
- package/dist/src/execution/compact.d.ts +128 -1
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +91 -0
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +2 -3
- package/dist/src/execution/utils.d.ts +6 -5
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +37 -17
- package/dist/src/index.d.ts +8 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +89 -31
- package/dist/src/modules/index.d.ts +3 -8
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +26 -27
- package/dist/src/modules/index.test.js +1 -4
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +19 -14
- package/dist/src/modules/validators/core.test.js +4 -11
- package/dist/src/modules/validators/index.d.ts +1 -2
- package/dist/src/modules/validators/index.d.ts.map +1 -1
- package/dist/src/modules/validators/index.js +1 -13
- package/dist/src/modules/validators/smart-sessions.js +3 -3
- package/dist/src/modules/validators/smart-sessions.test.js +4 -4
- package/dist/src/orchestrator/index.d.ts +1 -2
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +1 -3
- package/dist/src/orchestrator/utils.d.ts +1 -3
- package/dist/src/orchestrator/utils.d.ts.map +1 -1
- package/dist/src/orchestrator/utils.js +0 -102
- package/dist/src/types.d.ts +2 -5
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -10,16 +10,15 @@ exports.signEip7702InitData = signEip7702InitData;
|
|
|
10
10
|
exports.getEip7702InitCall = getEip7702InitCall;
|
|
11
11
|
exports.isDeployed = isDeployed;
|
|
12
12
|
exports.deploy = deploy;
|
|
13
|
+
exports.toErc6492Signature = toErc6492Signature;
|
|
13
14
|
exports.getSmartAccount = getSmartAccount;
|
|
14
15
|
exports.getSmartSessionSmartAccount = getSmartSessionSmartAccount;
|
|
15
16
|
exports.getGuardianSmartAccount = getGuardianSmartAccount;
|
|
16
17
|
exports.getPackedSignature = getPackedSignature;
|
|
17
|
-
exports.
|
|
18
|
+
exports.getTypedDataPackedSignature = getTypedDataPackedSignature;
|
|
18
19
|
const viem_1 = require("viem");
|
|
19
|
-
const p256_1 = require("@noble/curves/p256");
|
|
20
20
|
const execution_1 = require("../execution");
|
|
21
21
|
const smart_session_1 = require("../execution/smart-session");
|
|
22
|
-
const modules_1 = require("../modules");
|
|
23
22
|
const validators_1 = require("../modules/validators");
|
|
24
23
|
const core_1 = require("../modules/validators/core");
|
|
25
24
|
const error_1 = require("./error");
|
|
@@ -35,6 +34,9 @@ Object.defineProperty(exports, "SmartSessionsNotEnabledError", { enumerable: tru
|
|
|
35
34
|
const kernel_1 = require("./kernel");
|
|
36
35
|
const nexus_1 = require("./nexus");
|
|
37
36
|
const safe_1 = require("./safe");
|
|
37
|
+
const common_1 = require("./signing/common");
|
|
38
|
+
const message_1 = require("./signing/message");
|
|
39
|
+
const typedData_1 = require("./signing/typedData");
|
|
38
40
|
const startale_1 = require("./startale");
|
|
39
41
|
const utils_1 = require("./utils");
|
|
40
42
|
function getDeployArgs(config) {
|
|
@@ -180,26 +182,56 @@ function getAddress(config) {
|
|
|
180
182
|
}
|
|
181
183
|
// Signs and packs a signature to be EIP-1271 compatible
|
|
182
184
|
async function getPackedSignature(config, signers, chain, validator, hash, transformSignature = (signature) => signature) {
|
|
183
|
-
signers = signers ?? convertOwnerSetToSignerSet(config.owners);
|
|
184
|
-
const signFn = (hash) => sign(signers, chain, hash);
|
|
185
|
+
signers = signers ?? (0, common_1.convertOwnerSetToSignerSet)(config.owners);
|
|
186
|
+
const signFn = (hash) => (0, message_1.sign)(signers, chain, hash);
|
|
185
187
|
const account = getAccountProvider(config);
|
|
186
188
|
const address = getAddress(config);
|
|
187
189
|
switch (account.type) {
|
|
188
190
|
case 'safe': {
|
|
189
|
-
|
|
191
|
+
const signature = await signFn(hash);
|
|
192
|
+
return (0, safe_1.packSignature)(signature, validator, transformSignature);
|
|
190
193
|
}
|
|
191
194
|
case 'nexus': {
|
|
192
|
-
|
|
195
|
+
const signature = await signFn(hash);
|
|
196
|
+
return (0, nexus_1.packSignature)(signature, validator, transformSignature);
|
|
193
197
|
}
|
|
194
198
|
case 'kernel': {
|
|
195
|
-
|
|
199
|
+
const signature = await signFn((0, kernel_1.wrapMessageHash)(hash, address));
|
|
200
|
+
return (0, kernel_1.packSignature)(signature, validator, transformSignature);
|
|
196
201
|
}
|
|
197
202
|
case 'startale': {
|
|
198
|
-
|
|
203
|
+
const signature = await signFn(hash);
|
|
204
|
+
return (0, startale_1.packSignature)(signature, validator, transformSignature);
|
|
199
205
|
}
|
|
200
206
|
}
|
|
201
207
|
}
|
|
202
|
-
|
|
208
|
+
// Signs and packs a signature to be EIP-1271 compatible
|
|
209
|
+
async function getTypedDataPackedSignature(config, signers, chain, validator, parameters, transformSignature = (signature) => signature) {
|
|
210
|
+
signers = signers ?? (0, common_1.convertOwnerSetToSignerSet)(config.owners);
|
|
211
|
+
const signFn = (parameters) => (0, typedData_1.sign)(signers, chain, parameters);
|
|
212
|
+
const account = getAccountProvider(config);
|
|
213
|
+
switch (account.type) {
|
|
214
|
+
case 'safe': {
|
|
215
|
+
const signature = await signFn(parameters);
|
|
216
|
+
return (0, safe_1.packSignature)(signature, validator, transformSignature);
|
|
217
|
+
}
|
|
218
|
+
case 'nexus': {
|
|
219
|
+
const signature = await signFn(parameters);
|
|
220
|
+
return (0, nexus_1.packSignature)(signature, validator, transformSignature);
|
|
221
|
+
}
|
|
222
|
+
case 'kernel': {
|
|
223
|
+
const address = getAddress(config);
|
|
224
|
+
const signMessageFn = (hash) => (0, message_1.sign)(signers, chain, hash);
|
|
225
|
+
const signature = await signMessageFn((0, kernel_1.wrapMessageHash)((0, viem_1.hashTypedData)(parameters), address));
|
|
226
|
+
return (0, kernel_1.packSignature)(signature, validator, transformSignature);
|
|
227
|
+
}
|
|
228
|
+
case 'startale': {
|
|
229
|
+
const signature = await signFn(parameters);
|
|
230
|
+
return (0, startale_1.packSignature)(signature, validator, transformSignature);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
async function isDeployed(config, chain) {
|
|
203
235
|
const publicClient = (0, viem_1.createPublicClient)({
|
|
204
236
|
chain: chain,
|
|
205
237
|
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
@@ -234,7 +266,7 @@ async function deployWithIntent(chain, config) {
|
|
|
234
266
|
// Already deployed
|
|
235
267
|
return;
|
|
236
268
|
}
|
|
237
|
-
await (0, execution_1.sendTransaction)(config, {
|
|
269
|
+
const result = await (0, execution_1.sendTransaction)(config, {
|
|
238
270
|
targetChain: chain,
|
|
239
271
|
calls: [
|
|
240
272
|
{
|
|
@@ -243,42 +275,35 @@ async function deployWithIntent(chain, config) {
|
|
|
243
275
|
},
|
|
244
276
|
],
|
|
245
277
|
});
|
|
278
|
+
await (0, execution_1.waitForExecution)(config, result, true);
|
|
246
279
|
}
|
|
247
|
-
async function
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
const address = getAddress(config);
|
|
252
|
-
const alreadyDeployed = await isDeployed(chain, config);
|
|
253
|
-
if (alreadyDeployed) {
|
|
254
|
-
return address;
|
|
280
|
+
async function toErc6492Signature(config, signature, chain) {
|
|
281
|
+
const deployed = await isDeployed(config, chain);
|
|
282
|
+
if (deployed) {
|
|
283
|
+
return signature;
|
|
255
284
|
}
|
|
256
|
-
|
|
257
|
-
|
|
285
|
+
// Account is not deployed, use ERC-6492
|
|
286
|
+
const initCode = getInitCode(config);
|
|
287
|
+
if (!initCode) {
|
|
258
288
|
throw new error_1.FactoryArgsNotAvailableError();
|
|
259
289
|
}
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
to: factory,
|
|
271
|
-
data: factoryData,
|
|
272
|
-
});
|
|
273
|
-
await publicClient.waitForTransactionReceipt({ hash });
|
|
274
|
-
return address;
|
|
290
|
+
const { factory, factoryData } = initCode;
|
|
291
|
+
const magicBytes = '0x6492649264926492649264926492649264926492649264926492649264926492';
|
|
292
|
+
return (0, viem_1.concat)([
|
|
293
|
+
(0, viem_1.encodeAbiParameters)([
|
|
294
|
+
{ name: 'create2Factory', type: 'address' },
|
|
295
|
+
{ name: 'factoryCalldata', type: 'bytes' },
|
|
296
|
+
{ name: 'originalERC1271Signature', type: 'bytes' },
|
|
297
|
+
], [factory, factoryData, signature]),
|
|
298
|
+
magicBytes,
|
|
299
|
+
]);
|
|
275
300
|
}
|
|
276
301
|
async function getSmartAccount(config, client, chain) {
|
|
277
302
|
const account = getAccountProvider(config);
|
|
278
303
|
const address = getAddress(config);
|
|
279
304
|
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
280
|
-
const signers = convertOwnerSetToSignerSet(config.owners);
|
|
281
|
-
const signFn = (hash) => sign(signers, chain, hash);
|
|
305
|
+
const signers = (0, common_1.convertOwnerSetToSignerSet)(config.owners);
|
|
306
|
+
const signFn = (hash) => (0, message_1.sign)(signers, chain, hash);
|
|
282
307
|
switch (account.type) {
|
|
283
308
|
case 'safe': {
|
|
284
309
|
return (0, safe_1.getSmartAccount)(client, address, config.owners, ownerValidator.address, signFn);
|
|
@@ -305,7 +330,7 @@ async function getSmartSessionSmartAccount(config, client, chain, session, enabl
|
|
|
305
330
|
session,
|
|
306
331
|
enableData: enableData || undefined,
|
|
307
332
|
};
|
|
308
|
-
const signFn = (hash) => sign(signers, chain, hash);
|
|
333
|
+
const signFn = (hash) => (0, message_1.sign)(signers, chain, hash);
|
|
309
334
|
const account = getAccountProvider(config);
|
|
310
335
|
switch (account.type) {
|
|
311
336
|
case 'safe': {
|
|
@@ -333,7 +358,7 @@ async function getGuardianSmartAccount(config, client, chain, guardians) {
|
|
|
333
358
|
type: 'guardians',
|
|
334
359
|
guardians: accounts,
|
|
335
360
|
};
|
|
336
|
-
const signFn = (hash) => sign(signers, chain, hash);
|
|
361
|
+
const signFn = (hash) => (0, message_1.sign)(signers, chain, hash);
|
|
337
362
|
const account = getAccountProvider(config);
|
|
338
363
|
switch (account.type) {
|
|
339
364
|
case 'safe': {
|
|
@@ -350,139 +375,6 @@ async function getGuardianSmartAccount(config, client, chain, guardians) {
|
|
|
350
375
|
}
|
|
351
376
|
}
|
|
352
377
|
}
|
|
353
|
-
async function sign(signers, chain, hash) {
|
|
354
|
-
switch (signers.type) {
|
|
355
|
-
case 'owner': {
|
|
356
|
-
switch (signers.kind) {
|
|
357
|
-
case 'ecdsa': {
|
|
358
|
-
const signatures = await Promise.all(signers.accounts.map((account) => signEcdsa(account, hash)));
|
|
359
|
-
return (0, viem_1.concat)(signatures);
|
|
360
|
-
}
|
|
361
|
-
case 'passkey': {
|
|
362
|
-
// Convert OwnerSignerSet to WebauthnValidatorConfig
|
|
363
|
-
const webAuthnConfig = {
|
|
364
|
-
type: 'passkey',
|
|
365
|
-
account: signers.account,
|
|
366
|
-
credentialIds: signers.credentialIds
|
|
367
|
-
};
|
|
368
|
-
return await signPasskey(webAuthnConfig, chain, hash);
|
|
369
|
-
}
|
|
370
|
-
case 'multi-factor': {
|
|
371
|
-
const signatures = await Promise.all(signers.validators.map(async (validator) => {
|
|
372
|
-
if (validator === null) {
|
|
373
|
-
return '0x';
|
|
374
|
-
}
|
|
375
|
-
// Convert to proper validator format
|
|
376
|
-
const validatorConfig = validator.type === 'ecdsa'
|
|
377
|
-
? { type: 'ecdsa', accounts: validator.accounts, threshold: 1 }
|
|
378
|
-
: { type: 'passkey', account: validator.account, credentialIds: validator.credentialIds };
|
|
379
|
-
const validatorSigners = convertOwnerSetToSignerSet(validatorConfig);
|
|
380
|
-
return sign(validatorSigners, chain, hash);
|
|
381
|
-
}));
|
|
382
|
-
const data = (0, viem_1.encodeAbiParameters)([
|
|
383
|
-
{
|
|
384
|
-
components: [
|
|
385
|
-
{
|
|
386
|
-
internalType: 'bytes32',
|
|
387
|
-
name: 'packedValidatorAndId',
|
|
388
|
-
type: 'bytes32',
|
|
389
|
-
},
|
|
390
|
-
{ internalType: 'bytes', name: 'data', type: 'bytes' },
|
|
391
|
-
],
|
|
392
|
-
name: 'validators',
|
|
393
|
-
type: 'tuple[]',
|
|
394
|
-
},
|
|
395
|
-
], [
|
|
396
|
-
signers.validators.map((validator, index) => {
|
|
397
|
-
// Convert to proper validator format for getValidator
|
|
398
|
-
const validatorConfig = validator.type === 'ecdsa'
|
|
399
|
-
? { type: 'ecdsa', accounts: validator.accounts, threshold: 1 }
|
|
400
|
-
: { type: 'passkey', account: validator.account, credentialIds: validator.credentialIds };
|
|
401
|
-
const validatorModule = (0, core_1.getValidator)(validatorConfig);
|
|
402
|
-
return {
|
|
403
|
-
packedValidatorAndId: (0, viem_1.concat)([
|
|
404
|
-
(0, viem_1.pad)((0, viem_1.toHex)(validator.id), { size: 12 }),
|
|
405
|
-
validatorModule.address,
|
|
406
|
-
]),
|
|
407
|
-
data: signatures[index],
|
|
408
|
-
};
|
|
409
|
-
}),
|
|
410
|
-
]);
|
|
411
|
-
return data;
|
|
412
|
-
}
|
|
413
|
-
default: {
|
|
414
|
-
throw new Error('Unsupported owner kind');
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
case 'session': {
|
|
419
|
-
const sessionSigners = convertOwnerSetToSignerSet(signers.session.owners);
|
|
420
|
-
return sign(sessionSigners, chain, hash);
|
|
421
|
-
}
|
|
422
|
-
case 'guardians': {
|
|
423
|
-
const signatures = await Promise.all(signers.guardians.map((account) => signEcdsa(account, hash)));
|
|
424
|
-
return (0, viem_1.concat)(signatures);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
async function signEcdsa(account, hash) {
|
|
429
|
-
if (!account.signMessage) {
|
|
430
|
-
throw new error_1.SigningNotSupportedForAccountError();
|
|
431
|
-
}
|
|
432
|
-
return await account.signMessage({ message: { raw: hash } });
|
|
433
|
-
}
|
|
434
|
-
async function signPasskey(validators, chain, hash) {
|
|
435
|
-
const { account, credentialIds } = validators;
|
|
436
|
-
console.log('credentialIds in the signPasskey', credentialIds);
|
|
437
|
-
const { webauthn: rawWebauthn, signature } = await account.sign({ hash });
|
|
438
|
-
console.log('rawWebauthn in the signPasskey', rawWebauthn);
|
|
439
|
-
console.log('signature in the signPasskey', signature);
|
|
440
|
-
const { authenticatorData, clientDataJSON, challengeIndex, typeIndex } = rawWebauthn;
|
|
441
|
-
const usePrecompiled = (0, modules_1.isRip7212SupportedNetwork)(chain);
|
|
442
|
-
// Convert signature to object { r, s } in r||s format using noble p256
|
|
443
|
-
function lowSNormalize(r, s) {
|
|
444
|
-
const n = BigInt('0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551');
|
|
445
|
-
if (s > n / 2n)
|
|
446
|
-
return { r, s: n - s };
|
|
447
|
-
return { r, s };
|
|
448
|
-
}
|
|
449
|
-
function toRS(sig) {
|
|
450
|
-
if (typeof sig === 'object' && 'r' in sig && 's' in sig) {
|
|
451
|
-
return lowSNormalize(sig.r, sig.s);
|
|
452
|
-
}
|
|
453
|
-
const bytes = typeof sig === 'string' ? (0, viem_1.hexToBytes)(sig) : sig;
|
|
454
|
-
let compact;
|
|
455
|
-
if (bytes.length > 0 && bytes[0] === 0x30) {
|
|
456
|
-
// DER
|
|
457
|
-
const derSig = p256_1.secp256r1.Signature.fromDER(bytes);
|
|
458
|
-
compact = derSig.toCompactRawBytes(); // 64 bytes r||s
|
|
459
|
-
}
|
|
460
|
-
else if (bytes.length === 64) {
|
|
461
|
-
compact = bytes;
|
|
462
|
-
}
|
|
463
|
-
else if (typeof sig === 'string' && sig.length === 2 + 64 * 2) {
|
|
464
|
-
// Hex r||s
|
|
465
|
-
compact = (0, viem_1.hexToBytes)(sig);
|
|
466
|
-
}
|
|
467
|
-
else {
|
|
468
|
-
// Fallback: treat as r||s if size permits
|
|
469
|
-
compact = bytes;
|
|
470
|
-
}
|
|
471
|
-
const rHex = (0, viem_1.bytesToHex)(compact.slice(0, 32));
|
|
472
|
-
const sHex = (0, viem_1.bytesToHex)(compact.slice(32, 64));
|
|
473
|
-
const r = BigInt(rHex);
|
|
474
|
-
const s = BigInt(sHex);
|
|
475
|
-
return lowSNormalize(r, s);
|
|
476
|
-
}
|
|
477
|
-
const processedSignature = toRS(signature);
|
|
478
|
-
console.log('processedSignature in the signPasskey', processedSignature);
|
|
479
|
-
return (0, modules_1.getWebauthnValidatorSignature)({
|
|
480
|
-
credentialIds,
|
|
481
|
-
usePrecompiled,
|
|
482
|
-
webauthn: { authenticatorData, clientDataJSON, challengeIndex, typeIndex },
|
|
483
|
-
signature: processedSignature,
|
|
484
|
-
});
|
|
485
|
-
}
|
|
486
378
|
function is7702(config) {
|
|
487
379
|
return config.eoa !== undefined;
|
|
488
380
|
}
|
|
@@ -494,40 +386,3 @@ function getAccountProvider(config) {
|
|
|
494
386
|
type: 'nexus',
|
|
495
387
|
};
|
|
496
388
|
}
|
|
497
|
-
function convertOwnerSetToSignerSet(owners) {
|
|
498
|
-
switch (owners.type) {
|
|
499
|
-
case 'ecdsa': {
|
|
500
|
-
return {
|
|
501
|
-
type: 'owner',
|
|
502
|
-
kind: 'ecdsa',
|
|
503
|
-
accounts: owners.accounts,
|
|
504
|
-
};
|
|
505
|
-
}
|
|
506
|
-
case 'passkey': {
|
|
507
|
-
const { account, credentialIds } = owners;
|
|
508
|
-
return {
|
|
509
|
-
type: 'owner',
|
|
510
|
-
kind: 'passkey',
|
|
511
|
-
account,
|
|
512
|
-
credentialIds,
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
case 'multi-factor': {
|
|
516
|
-
// Filter out null entries and propagate credentialIds
|
|
517
|
-
const mf = owners;
|
|
518
|
-
const validValidators = mf.validators.filter((v) => v !== null);
|
|
519
|
-
return {
|
|
520
|
-
type: 'owner',
|
|
521
|
-
kind: 'multi-factor',
|
|
522
|
-
validators: validValidators.map((validator, index) => {
|
|
523
|
-
if (validator.type === 'ecdsa') {
|
|
524
|
-
return { type: 'ecdsa', id: index, accounts: validator.accounts };
|
|
525
|
-
}
|
|
526
|
-
else {
|
|
527
|
-
return { type: 'passkey', id: index, account: validator.account, credentialIds: validator.credentialIds };
|
|
528
|
-
}
|
|
529
|
-
}),
|
|
530
|
-
};
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
}
|
|
@@ -14,18 +14,17 @@ const _1 = require(".");
|
|
|
14
14
|
},
|
|
15
15
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
16
16
|
});
|
|
17
|
-
(0, vitest_1.expect)(address).toEqual('
|
|
17
|
+
(0, vitest_1.expect)(address).toEqual('0x7fbe9b0796484c06c94968b910a4cf488fd1719b');
|
|
18
18
|
});
|
|
19
19
|
(0, vitest_1.test)('Safe, passkey owner with a session', () => {
|
|
20
20
|
const address = (0, _1.getAddress)({
|
|
21
21
|
owners: {
|
|
22
22
|
type: 'passkey',
|
|
23
23
|
account: consts_1.passkeyAccount,
|
|
24
|
-
credentialIds: ['0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'],
|
|
25
24
|
},
|
|
26
25
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
27
26
|
});
|
|
28
|
-
(0, vitest_1.expect)(address).toEqual('
|
|
27
|
+
(0, vitest_1.expect)(address).toEqual('0x82a8a51443c2b8608001bdc4ff5bb31f69e8ed14');
|
|
29
28
|
});
|
|
30
29
|
});
|
|
31
30
|
(0, vitest_1.describe)('Sign', () => {
|
|
@@ -13,9 +13,10 @@ declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
|
13
13
|
};
|
|
14
14
|
declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
|
|
15
15
|
declare function getInstallData(module: Module): Hex[];
|
|
16
|
-
declare function
|
|
16
|
+
declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
|
|
17
|
+
declare function wrapMessageHash(messageHash: Hex, accountAddress: Hex): Hex;
|
|
17
18
|
declare function getSmartAccount(client: PublicClient, address: Address, owners: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
18
19
|
declare function getSessionSmartAccount(client: PublicClient, address: Address, session: Session, validatorAddress: Address, enableData: EnableSessionData | null, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
19
20
|
declare function getGuardianSmartAccount(client: PublicClient, address: Address, guardians: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
20
|
-
export { getInstallData, getAddress, getDeployArgs, getSmartAccount, getSessionSmartAccount, getGuardianSmartAccount,
|
|
21
|
+
export { getInstallData, getAddress, getDeployArgs, getSmartAccount, getSessionSmartAccount, getGuardianSmartAccount, packSignature, wrapMessageHash, };
|
|
21
22
|
//# sourceMappingURL=kernel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../../../accounts/kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EACR,KAAK,OAAO,EAQZ,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;AAC1E,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAgBhF,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;EA4CrD;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,iBASlD;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,EAAE,CAsE7C;AAED,iBAAe,
|
|
1
|
+
{"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../../../accounts/kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EACR,KAAK,OAAO,EAQZ,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;AAC1E,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAgBhF,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;EA4CrD;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"}
|
|
@@ -6,7 +6,8 @@ exports.getDeployArgs = getDeployArgs;
|
|
|
6
6
|
exports.getSmartAccount = getSmartAccount;
|
|
7
7
|
exports.getSessionSmartAccount = getSessionSmartAccount;
|
|
8
8
|
exports.getGuardianSmartAccount = getGuardianSmartAccount;
|
|
9
|
-
exports.
|
|
9
|
+
exports.packSignature = packSignature;
|
|
10
|
+
exports.wrapMessageHash = wrapMessageHash;
|
|
10
11
|
const viem_1 = require("viem");
|
|
11
12
|
const account_abstraction_1 = require("viem/account-abstraction");
|
|
12
13
|
const modules_1 = require("../modules");
|
|
@@ -126,11 +127,8 @@ function getInstallData(module) {
|
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
|
-
async function
|
|
130
|
+
async function packSignature(signature, validator, transformSignature = (signature) => signature) {
|
|
130
131
|
const vId = validator.isRoot ? '0x00' : (0, viem_1.concat)(['0x01', validator.address]);
|
|
131
|
-
const signature = validator.isRoot
|
|
132
|
-
? await signFn(wrapMessageHash(hash, accountAddress))
|
|
133
|
-
: await signFn(hash);
|
|
134
132
|
const magicValueSigReplayable = (0, viem_1.keccak256)((0, viem_1.toHex)('kernel.replayable.signature'));
|
|
135
133
|
const packedSig = (0, viem_1.concat)([
|
|
136
134
|
vId,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const viem_1 = require("viem");
|
|
4
3
|
const vitest_1 = require("vitest");
|
|
5
4
|
const consts_1 = require("../../test/consts");
|
|
6
5
|
const common_1 = require("../modules/common");
|
|
@@ -17,17 +16,16 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
17
16
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
18
17
|
});
|
|
19
18
|
(0, vitest_1.expect)(factory).toEqual('0xd703aae79538628d27099b8c4f621be4ccd142d5');
|
|
20
|
-
(0, vitest_1.expect)(factoryData).toEqual('
|
|
19
|
+
(0, vitest_1.expect)(factoryData).toEqual('0xc5265d5d0000000000000000000000002577507b78c2008ff367261cb6285d44ba5ef2e90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003243c3b752b0120C008719Ba9D8aA14C7d07D122cd5E965aA8da50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000094000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
21
20
|
(0, vitest_1.expect)(salt).toEqual('0x0000000000000000000000000000000000000000000000000000000000000000');
|
|
22
21
|
(0, vitest_1.expect)(implementation).toEqual('0xd6CEDDe84be40893d153Be9d467CD6aD37875b28');
|
|
23
|
-
(0, vitest_1.expect)(initializationCallData).toEqual('
|
|
22
|
+
(0, vitest_1.expect)(initializationCallData).toEqual('0x3c3b752b0120C008719Ba9D8aA14C7d07D122cd5E965aA8da50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
24
23
|
});
|
|
25
24
|
(0, vitest_1.test)('Passkey owner', () => {
|
|
26
25
|
const { factory, factoryData, salt, implementation, initializationCallData, } = (0, kernel_1.getDeployArgs)({
|
|
27
26
|
owners: {
|
|
28
27
|
type: 'passkey',
|
|
29
28
|
account: consts_1.passkeyAccount,
|
|
30
|
-
credentialIds: ['0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'],
|
|
31
29
|
},
|
|
32
30
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
33
31
|
});
|
|
@@ -47,14 +45,13 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
47
45
|
},
|
|
48
46
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
49
47
|
});
|
|
50
|
-
(0, vitest_1.expect)(address).toEqual('
|
|
48
|
+
(0, vitest_1.expect)(address).toEqual('0x43bb2f5505a463c57C9688678cC9DB8d10729747');
|
|
51
49
|
});
|
|
52
50
|
(0, vitest_1.test)('Passkey owner', () => {
|
|
53
51
|
const address = (0, kernel_1.getAddress)({
|
|
54
52
|
owners: {
|
|
55
53
|
type: 'passkey',
|
|
56
54
|
account: consts_1.passkeyAccount,
|
|
57
|
-
credentialIds: ['0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'],
|
|
58
55
|
},
|
|
59
56
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
60
57
|
});
|
|
@@ -79,25 +76,21 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
79
76
|
(0, vitest_1.describe)('Get Packed Signature', () => {
|
|
80
77
|
(0, vitest_1.describe)('Mock signature', () => {
|
|
81
78
|
(0, vitest_1.test)('Root validator', async () => {
|
|
82
|
-
const hash = (0, viem_1.keccak256)('0xabcd');
|
|
83
79
|
const mockSignature = '0x1234';
|
|
84
|
-
const accountAddress = '0xa80ed905adbd7cba128aaf64a1fa33a530b9b0aa';
|
|
85
80
|
const validator = {
|
|
86
81
|
address: '0xe35b75e5ec3c04e9cefa8e581fbee859f56edeb4',
|
|
87
82
|
isRoot: true,
|
|
88
83
|
};
|
|
89
|
-
const signature = await (0, kernel_1.
|
|
84
|
+
const signature = await (0, kernel_1.packSignature)(mockSignature, validator);
|
|
90
85
|
(0, vitest_1.expect)(signature).toEqual('0x000555ad2729e8da1777a4e5020806f8bf7601c3db6bfe402f410a34958363a95a1234');
|
|
91
86
|
});
|
|
92
87
|
(0, vitest_1.test)('Non-root validator', async () => {
|
|
93
|
-
const hash = (0, viem_1.keccak256)('0xabcd');
|
|
94
88
|
const mockSignature = '0x1234';
|
|
95
|
-
const accountAddress = '0xa80ed905adbd7cba128aaf64a1fa33a530b9b0aa';
|
|
96
89
|
const validator = {
|
|
97
90
|
address: '0xe35b75e5ec3c04e9cefa8e581fbee859f56edeb4',
|
|
98
91
|
isRoot: false,
|
|
99
92
|
};
|
|
100
|
-
const signature = await (0, kernel_1.
|
|
93
|
+
const signature = await (0, kernel_1.packSignature)(mockSignature, validator);
|
|
101
94
|
(0, vitest_1.expect)(signature).toEqual('0x01e35b75e5ec3c04e9cefa8e581fbee859f56edeb40555ad2729e8da1777a4e5020806f8bf7601c3db6bfe402f410a34958363a95a1234');
|
|
102
95
|
});
|
|
103
96
|
});
|
|
@@ -14,7 +14,7 @@ declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
|
14
14
|
};
|
|
15
15
|
declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
|
|
16
16
|
declare function getInstallData(module: Module): `0x${string}`;
|
|
17
|
-
declare function
|
|
17
|
+
declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex, defaultValidatorAddress?: Address): Promise<`0x${string}`>;
|
|
18
18
|
declare function getSmartAccount(client: PublicClient, address: Address, owners: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>, defaultValidatorAddress?: Address): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
19
19
|
declare function getSessionSmartAccount(client: PublicClient, address: Address, session: Session, validatorAddress: Address, enableData: EnableSessionData | null, sign: (hash: Hex) => Promise<Hex>, defaultValidatorAddress?: Address): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
20
20
|
declare function getGuardianSmartAccount(client: PublicClient, address: Address, guardians: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>, defaultValidatorAddress?: Address): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
@@ -23,5 +23,5 @@ declare function getEip7702InitCall(config: RhinestoneAccountConfig, signature:
|
|
|
23
23
|
initData: `0x${string}`;
|
|
24
24
|
contract: `0x${string}`;
|
|
25
25
|
}>;
|
|
26
|
-
export { getInstallData, getAddress,
|
|
26
|
+
export { getInstallData, getAddress, packSignature, getDeployArgs, getSmartAccount, getSessionSmartAccount, getGuardianSmartAccount, signEip7702InitData, getEip7702InitCall, };
|
|
27
27
|
//# sourceMappingURL=nexus.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nexus.d.ts","sourceRoot":"","sources":["../../../accounts/nexus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAYpE,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAEhC,MAAM,0BAA0B,CAAA;AAGjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAS/C,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;
|
|
1
|
+
{"version":3,"file":"nexus.d.ts","sourceRoot":"","sources":["../../../accounts/nexus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAYpE,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAEhC,MAAM,0BAA0B,CAAA;AAGjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAS/C,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;AAchF,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;;EAoErD;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,iBA4BlD;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE,MAAM,iBA2BrC;AAED,iBAAe,aAAa,CAC1B,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,eAAe,EAC1B,kBAAkB,GAAE,CAAC,SAAS,EAAE,GAAG,KAAK,GAA8B,EACtE,uBAAuB,GAAE,OAAyC,0BAWnE;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,EACjC,uBAAuB,GAAE,OAAyC,iEAYnE;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,EACjC,uBAAuB,GAAE,OAAyC,iEAwCnE;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,EACjC,uBAAuB,GAAE,OAAyC,iEAcnE;AAqFD,iBAAe,mBAAmB,CAChC,MAAM,EAAE,uBAAuB,EAC/B,GAAG,EAAE,OAAO,0BA0Bb;AAED,iBAAe,kBAAkB,CAC/B,MAAM,EAAE,uBAAuB,EAC/B,SAAS,EAAE,GAAG;;;GAuCf;AAED,OAAO,EACL,cAAc,EACd,UAAU,EACV,aAAa,EACb,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,GACnB,CAAA"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getInstallData = getInstallData;
|
|
4
4
|
exports.getAddress = getAddress;
|
|
5
|
-
exports.
|
|
5
|
+
exports.packSignature = packSignature;
|
|
6
6
|
exports.getDeployArgs = getDeployArgs;
|
|
7
7
|
exports.getSmartAccount = getSmartAccount;
|
|
8
8
|
exports.getSessionSmartAccount = getSessionSmartAccount;
|
|
@@ -16,27 +16,33 @@ const validators_1 = require("../modules/validators");
|
|
|
16
16
|
const core_1 = require("../modules/validators/core");
|
|
17
17
|
const error_1 = require("./error");
|
|
18
18
|
const utils_1 = require("./utils");
|
|
19
|
-
const NEXUS_DEFAULT_VALIDATOR_ADDRESS = core_1.
|
|
20
|
-
const NEXUS_IMPLEMENTATION_ADDRESS = '
|
|
21
|
-
const NEXUS_FACTORY_ADDRESS = '
|
|
22
|
-
const NEXUS_BOOTSTRAP_ADDRESS = '
|
|
19
|
+
const NEXUS_DEFAULT_VALIDATOR_ADDRESS = core_1.WEBAUTHN_VALIDATOR_ADDRESS;
|
|
20
|
+
const NEXUS_IMPLEMENTATION_ADDRESS = '0x55cc6609fDb3620ABeABf4dB020abfc469494778';
|
|
21
|
+
const NEXUS_FACTORY_ADDRESS = '0xFF4454d15707a6f6BF01540796040f9E1646322C';
|
|
22
|
+
const NEXUS_BOOTSTRAP_ADDRESS = '0x40E89A87C56A340c9257350dEDf4B89a3FcCCcD3';
|
|
23
23
|
const NEXUS_CREATION_CODE = '0x60806040526102aa803803806100148161018c565b92833981016040828203126101885781516001600160a01b03811692909190838303610188576020810151906001600160401b03821161018857019281601f8501121561018857835161006e610069826101c5565b61018c565b9481865260208601936020838301011161018857815f926020809301865e8601015260017f90b772c2cb8a51aa7a8a65fc23543c6d022d5b3f8e2b92eed79fba7eef8293005d823b15610176577f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b031916821790557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b5f80a282511561015e575f8091610146945190845af43d15610156573d91610137610069846101c5565b9283523d5f602085013e6101e0565b505b604051606b908161023f8239f35b6060916101e0565b50505034156101485763b398979f60e01b5f5260045ffd5b634c9c8ce360e01b5f5260045260245ffd5b5f80fd5b6040519190601f01601f191682016001600160401b038111838210176101b157604052565b634e487b7160e01b5f52604160045260245ffd5b6001600160401b0381116101b157601f01601f191660200190565b9061020457508051156101f557805190602001fd5b63d6bda27560e01b5f5260045ffd5b81511580610235575b610215575090565b639996b31560e01b5f9081526001600160a01b0391909116600452602490fd5b50803b1561020d56fe60806040523615605c575f8073ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416368280378136915af43d5f803e156058573d5ff35b3d5ffd5b00fea164736f6c634300081b000a';
|
|
24
24
|
function getDeployArgs(config) {
|
|
25
25
|
const salt = (0, viem_1.keccak256)('0x');
|
|
26
26
|
const moduleSetup = (0, modules_1.getSetup)(config);
|
|
27
|
-
|
|
27
|
+
// Filter out the default validator
|
|
28
|
+
const defaultValidator = moduleSetup.validators.find((v) => v.address === NEXUS_DEFAULT_VALIDATOR_ADDRESS);
|
|
29
|
+
const defaultValidatorInitData = defaultValidator
|
|
30
|
+
? defaultValidator.initData
|
|
31
|
+
: '0x';
|
|
32
|
+
console.log('[SDK] defaultValidatorInitData in the getDeployArgs', defaultValidatorInitData);
|
|
33
|
+
const validators = moduleSetup.validators.filter((v) => v.address !== NEXUS_DEFAULT_VALIDATOR_ADDRESS);
|
|
28
34
|
const initData = (0, viem_1.encodeAbiParameters)([{ type: 'address' }, { type: 'bytes' }], [
|
|
29
35
|
NEXUS_BOOTSTRAP_ADDRESS,
|
|
30
36
|
(0, viem_1.encodeFunctionData)({
|
|
31
37
|
abi: (0, viem_1.parseAbi)([
|
|
32
38
|
'struct BootstrapConfig {address module;bytes initData;}',
|
|
33
39
|
'struct BootstrapPreValidationHookConfig {uint256 hookType;address module;bytes data;}',
|
|
34
|
-
'
|
|
35
|
-
'function initNexus(BootstrapConfig[] calldata validators,BootstrapConfig[] calldata executors,BootstrapConfig calldata hook,BootstrapConfig[] calldata fallbacks,BootstrapPreValidationHookConfig[] calldata preValidationHooks,RegistryConfig registryConfig) external',
|
|
40
|
+
'function initNexusWithDefaultValidatorAndOtherModulesNoRegistry(bytes calldata defaultValidatorInitData,BootstrapConfig[] calldata validators,BootstrapConfig[] calldata executors,BootstrapConfig calldata hook,BootstrapConfig[] calldata fallbacks,BootstrapPreValidationHookConfig[] calldata preValidationHooks) external',
|
|
36
41
|
]),
|
|
37
|
-
functionName: '
|
|
42
|
+
functionName: 'initNexusWithDefaultValidatorAndOtherModulesNoRegistry',
|
|
38
43
|
args: [
|
|
39
|
-
|
|
44
|
+
defaultValidatorInitData,
|
|
45
|
+
validators.map((v) => ({
|
|
40
46
|
module: v.address,
|
|
41
47
|
initData: v.initData,
|
|
42
48
|
})),
|
|
@@ -53,11 +59,6 @@ function getDeployArgs(config) {
|
|
|
53
59
|
initData: f.initData,
|
|
54
60
|
})),
|
|
55
61
|
[],
|
|
56
|
-
{
|
|
57
|
-
registry: moduleSetup.registry,
|
|
58
|
-
attesters: moduleSetup.attesters,
|
|
59
|
-
threshold: moduleSetup.threshold,
|
|
60
|
-
},
|
|
61
62
|
],
|
|
62
63
|
}),
|
|
63
64
|
]);
|
|
@@ -125,8 +126,7 @@ function getInstallData(module) {
|
|
|
125
126
|
args: [module.type, module.address, module.initData],
|
|
126
127
|
});
|
|
127
128
|
}
|
|
128
|
-
async function
|
|
129
|
-
const signature = await signFn(hash);
|
|
129
|
+
async function packSignature(signature, validator, transformSignature = (signature) => signature, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
|
|
130
130
|
const validatorAddress = validator.address === defaultValidatorAddress
|
|
131
131
|
? viem_1.zeroAddress
|
|
132
132
|
: validator.address;
|