@charterlabs/rhinestone-sdk 0.2.6 → 0.2.7-dev.2
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/index.d.ts +3 -2
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +41 -8
- package/dist/src/accounts/index.test.js +3 -3
- 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/index.test.d.ts +2 -0
- package/dist/src/accounts/json-rpc/index.test.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/index.test.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 +14 -0
- package/dist/src/accounts/json-rpc/providers.test.d.ts +2 -0
- package/dist/src/accounts/json-rpc/providers.test.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/providers.test.js +15 -0
- package/dist/src/accounts/kernel.test.js +8 -8
- package/dist/src/accounts/nexus.d.ts +1 -2
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +43 -73
- package/dist/src/accounts/nexus.test.js +12 -12
- package/dist/src/accounts/safe.test.js +8 -8
- package/dist/src/accounts/signing/common.d.ts +10 -6
- package/dist/src/accounts/signing/common.d.ts.map +1 -1
- package/dist/src/accounts/signing/common.js +29 -9
- package/dist/src/accounts/signing/message.d.ts +2 -2
- package/dist/src/accounts/signing/message.d.ts.map +1 -1
- package/dist/src/accounts/signing/message.js +7 -9
- package/dist/src/accounts/signing/passkeys.d.ts +29 -0
- package/dist/src/accounts/signing/passkeys.d.ts.map +1 -0
- package/dist/src/accounts/signing/passkeys.js +90 -0
- package/dist/src/accounts/signing/passkeys.test.d.ts +2 -0
- package/dist/src/accounts/signing/passkeys.test.d.ts.map +1 -0
- package/dist/src/accounts/signing/passkeys.test.js +73 -0
- package/dist/src/accounts/signing/typedData.d.ts +2 -2
- package/dist/src/accounts/signing/typedData.d.ts.map +1 -1
- package/dist/src/accounts/signing/typedData.js +7 -9
- package/dist/src/accounts/startale.d.ts.map +1 -1
- package/dist/src/accounts/startale.js +1 -1
- package/dist/src/accounts/startale.test.js +8 -8
- package/dist/src/accounts/utils.d.ts +3 -3
- package/dist/src/accounts/utils.d.ts.map +1 -1
- package/dist/src/accounts/utils.js +3 -40
- package/dist/src/actions/index.d.ts +45 -1
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +168 -6
- package/dist/src/actions/index.test.js +16 -16
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +3 -6
- package/dist/src/execution/utils.d.ts +1 -1
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +12 -14
- package/dist/src/index.d.ts +7 -6
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +14 -3
- package/dist/src/modules/index.d.ts +2 -17
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +4 -49
- package/dist/src/modules/index.test.js +2 -22
- package/dist/src/modules/omni-account.d.ts +2 -1
- package/dist/src/modules/omni-account.d.ts.map +1 -1
- package/dist/src/modules/omni-account.js +3 -1
- package/dist/src/modules/validators/core.d.ts +2 -3
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +45 -43
- package/dist/src/modules/validators/core.test.js +6 -6
- package/dist/src/modules/validators/smart-sessions.test.js +4 -4
- package/dist/src/modules/validators/webauthn-contract.d.ts.map +1 -1
- package/dist/src/orchestrator/client.d.ts +2 -2
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/consts.d.ts +2 -1
- package/dist/src/orchestrator/consts.d.ts.map +1 -1
- package/dist/src/orchestrator/consts.js +3 -1
- package/dist/src/orchestrator/index.d.ts +1 -1
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.d.ts +1 -23
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +22 -24
- package/dist/src/orchestrator/registry.test.js +4 -4
- package/dist/src/orchestrator/types.d.ts +1 -6
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/types.d.ts +10 -4
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/src/orchestrator/registry.json +0 -365
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Chain, type HashTypedDataParameters, type Hex, type PublicClient, type TypedData } from 'viem';
|
|
1
|
+
import { type Chain, type Account, type HashTypedDataParameters, type Hex, type PublicClient, type TypedData } from 'viem';
|
|
2
2
|
import type { Module } from '../modules/common';
|
|
3
3
|
import type { EnableSessionData } from '../modules/validators/smart-sessions';
|
|
4
4
|
import type { AccountProviderConfig, Call, OwnerSet, RhinestoneAccountConfig, Session, SignerSet } from '../types';
|
|
@@ -20,10 +20,11 @@ declare function getPackedSignature(config: RhinestoneAccountConfig, signers: Si
|
|
|
20
20
|
declare function getTypedDataPackedSignature<typedData extends TypedData | Record<string, unknown> = TypedData, primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData>(config: RhinestoneAccountConfig, signers: SignerSet | undefined, chain: Chain, validator: ValidatorConfig, parameters: HashTypedDataParameters<typedData, primaryType>, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
|
|
21
21
|
declare function isDeployed(config: RhinestoneAccountConfig, chain: Chain): Promise<boolean>;
|
|
22
22
|
declare function deploy(config: RhinestoneAccountConfig, chain: Chain, session?: Session): Promise<void>;
|
|
23
|
+
declare function deployStandaloneWithEoa(chain: Chain, config: RhinestoneAccountConfig, deployer: Account): Promise<void>;
|
|
23
24
|
declare function toErc6492Signature(config: RhinestoneAccountConfig, signature: Hex, chain: Chain): Promise<Hex>;
|
|
24
25
|
declare function getSmartAccount(config: RhinestoneAccountConfig, client: PublicClient, chain: Chain): Promise<import("viem/_types/account-abstraction").SmartAccount<import("viem/_types/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">>>;
|
|
25
26
|
declare function getSmartSessionSmartAccount(config: RhinestoneAccountConfig, client: PublicClient, chain: Chain, session: Session, enableData: EnableSessionData | null): Promise<import("viem/_types/account-abstraction").SmartAccount<import("viem/_types/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">>>;
|
|
26
27
|
declare function getGuardianSmartAccount(config: RhinestoneAccountConfig, client: PublicClient, chain: Chain, guardians: OwnerSet): Promise<import("viem/_types/account-abstraction").SmartAccount<import("viem/_types/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">>>;
|
|
27
28
|
declare function getAccountProvider(config: RhinestoneAccountConfig): AccountProviderConfig;
|
|
28
|
-
export { getModuleInstallationCalls, getModuleUninstallationCalls, getAddress, getAccountProvider, getInitCode, signEip7702InitData, getEip7702InitCall, isDeployed, deploy, toErc6492Signature, getSmartAccount, getSmartSessionSmartAccount, getGuardianSmartAccount, getPackedSignature, getTypedDataPackedSignature, isAccountError, AccountError, Eip7702AccountMustHaveEoaError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, SmartSessionsNotEnabledError, SigningNotSupportedForAccountError, SignMessageNotSupportedByAccountError, Eip7702NotSupportedForAccountError, };
|
|
29
|
+
export { getModuleInstallationCalls, getModuleUninstallationCalls, getAddress, getAccountProvider, getInitCode, signEip7702InitData, getEip7702InitCall, isDeployed, deploy, deployStandaloneWithEoa, toErc6492Signature, getSmartAccount, getSmartSessionSmartAccount, getGuardianSmartAccount, getPackedSignature, getTypedDataPackedSignature, isAccountError, AccountError, Eip7702AccountMustHaveEoaError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, SmartSessionsNotEnabledError, SigningNotSupportedForAccountError, SignMessageNotSupportedByAccountError, Eip7702NotSupportedForAccountError, };
|
|
29
30
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../accounts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../accounts/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -10,6 +10,7 @@ exports.signEip7702InitData = signEip7702InitData;
|
|
|
10
10
|
exports.getEip7702InitCall = getEip7702InitCall;
|
|
11
11
|
exports.isDeployed = isDeployed;
|
|
12
12
|
exports.deploy = deploy;
|
|
13
|
+
exports.deployStandaloneWithEoa = deployStandaloneWithEoa;
|
|
13
14
|
exports.toErc6492Signature = toErc6492Signature;
|
|
14
15
|
exports.getSmartAccount = getSmartAccount;
|
|
15
16
|
exports.getSmartSessionSmartAccount = getSmartSessionSmartAccount;
|
|
@@ -183,7 +184,7 @@ function getAddress(config) {
|
|
|
183
184
|
// Signs and packs a signature to be EIP-1271 compatible
|
|
184
185
|
async function getPackedSignature(config, signers, chain, validator, hash, transformSignature = (signature) => signature) {
|
|
185
186
|
signers = signers ?? (0, common_1.convertOwnerSetToSignerSet)(config.owners);
|
|
186
|
-
const signFn = (hash) => (0, message_1.sign)(signers, chain, hash);
|
|
187
|
+
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash);
|
|
187
188
|
const account = getAccountProvider(config);
|
|
188
189
|
const address = getAddress(config);
|
|
189
190
|
switch (account.type) {
|
|
@@ -193,7 +194,7 @@ async function getPackedSignature(config, signers, chain, validator, hash, trans
|
|
|
193
194
|
}
|
|
194
195
|
case 'nexus': {
|
|
195
196
|
const signature = await signFn(hash);
|
|
196
|
-
return (0, nexus_1.packSignature)(signature, validator, transformSignature
|
|
197
|
+
return (0, nexus_1.packSignature)(signature, validator, transformSignature);
|
|
197
198
|
}
|
|
198
199
|
case 'kernel': {
|
|
199
200
|
const signature = await signFn((0, kernel_1.wrapMessageHash)(hash, address));
|
|
@@ -207,8 +208,9 @@ async function getPackedSignature(config, signers, chain, validator, hash, trans
|
|
|
207
208
|
}
|
|
208
209
|
// Signs and packs a signature to be EIP-1271 compatible
|
|
209
210
|
async function getTypedDataPackedSignature(config, signers, chain, validator, parameters, transformSignature = (signature) => signature) {
|
|
211
|
+
const address = getAddress(config);
|
|
210
212
|
signers = signers ?? (0, common_1.convertOwnerSetToSignerSet)(config.owners);
|
|
211
|
-
const signFn = (parameters) => (0, typedData_1.sign)(signers, chain, parameters);
|
|
213
|
+
const signFn = (parameters) => (0, typedData_1.sign)(signers, chain, address, parameters);
|
|
212
214
|
const account = getAccountProvider(config);
|
|
213
215
|
switch (account.type) {
|
|
214
216
|
case 'safe': {
|
|
@@ -217,11 +219,11 @@ async function getTypedDataPackedSignature(config, signers, chain, validator, pa
|
|
|
217
219
|
}
|
|
218
220
|
case 'nexus': {
|
|
219
221
|
const signature = await signFn(parameters);
|
|
220
|
-
return (0, nexus_1.packSignature)(signature, validator, transformSignature
|
|
222
|
+
return (0, nexus_1.packSignature)(signature, validator, transformSignature);
|
|
221
223
|
}
|
|
222
224
|
case 'kernel': {
|
|
223
225
|
const address = getAddress(config);
|
|
224
|
-
const signMessageFn = (hash) => (0, message_1.sign)(signers, chain, hash);
|
|
226
|
+
const signMessageFn = (hash) => (0, message_1.sign)(signers, chain, address, hash);
|
|
225
227
|
const signature = await signMessageFn((0, kernel_1.wrapMessageHash)((0, viem_1.hashTypedData)(parameters), address));
|
|
226
228
|
return (0, kernel_1.packSignature)(signature, validator, transformSignature);
|
|
227
229
|
}
|
|
@@ -277,6 +279,37 @@ async function deployWithIntent(chain, config) {
|
|
|
277
279
|
});
|
|
278
280
|
await (0, execution_1.waitForExecution)(config, result, true);
|
|
279
281
|
}
|
|
282
|
+
async function deployStandaloneWithEoa(chain, config, deployer) {
|
|
283
|
+
if (is7702(config)) {
|
|
284
|
+
const account = getAccountProvider(config);
|
|
285
|
+
throw new error_1.Eip7702NotSupportedForAccountError(account.type);
|
|
286
|
+
}
|
|
287
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
288
|
+
chain,
|
|
289
|
+
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
290
|
+
});
|
|
291
|
+
const address = getAddress(config);
|
|
292
|
+
const code = await publicClient.getCode({ address });
|
|
293
|
+
if (code && code !== '0x') {
|
|
294
|
+
// Already deployed
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
const initCode = getInitCode(config);
|
|
298
|
+
if (!initCode) {
|
|
299
|
+
throw new error_1.FactoryArgsNotAvailableError();
|
|
300
|
+
}
|
|
301
|
+
const { factory, factoryData } = initCode;
|
|
302
|
+
const walletClient = (0, viem_1.createWalletClient)({
|
|
303
|
+
account: deployer,
|
|
304
|
+
chain,
|
|
305
|
+
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
306
|
+
});
|
|
307
|
+
const hash = await walletClient.sendTransaction({
|
|
308
|
+
to: factory,
|
|
309
|
+
data: factoryData,
|
|
310
|
+
});
|
|
311
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
312
|
+
}
|
|
280
313
|
async function toErc6492Signature(config, signature, chain) {
|
|
281
314
|
const deployed = await isDeployed(config, chain);
|
|
282
315
|
if (deployed) {
|
|
@@ -303,7 +336,7 @@ async function getSmartAccount(config, client, chain) {
|
|
|
303
336
|
const address = getAddress(config);
|
|
304
337
|
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
305
338
|
const signers = (0, common_1.convertOwnerSetToSignerSet)(config.owners);
|
|
306
|
-
const signFn = (hash) => (0, message_1.sign)(signers, chain, hash);
|
|
339
|
+
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash);
|
|
307
340
|
switch (account.type) {
|
|
308
341
|
case 'safe': {
|
|
309
342
|
return (0, safe_1.getSmartAccount)(client, address, config.owners, ownerValidator.address, signFn);
|
|
@@ -330,7 +363,7 @@ async function getSmartSessionSmartAccount(config, client, chain, session, enabl
|
|
|
330
363
|
session,
|
|
331
364
|
enableData: enableData || undefined,
|
|
332
365
|
};
|
|
333
|
-
const signFn = (hash) => (0, message_1.sign)(signers, chain, hash);
|
|
366
|
+
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash);
|
|
334
367
|
const account = getAccountProvider(config);
|
|
335
368
|
switch (account.type) {
|
|
336
369
|
case 'safe': {
|
|
@@ -358,7 +391,7 @@ async function getGuardianSmartAccount(config, client, chain, guardians) {
|
|
|
358
391
|
type: 'guardians',
|
|
359
392
|
guardians: accounts,
|
|
360
393
|
};
|
|
361
|
-
const signFn = (hash) => (0, message_1.sign)(signers, chain, hash);
|
|
394
|
+
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash);
|
|
362
395
|
const account = getAccountProvider(config);
|
|
363
396
|
switch (account.type) {
|
|
364
397
|
case 'safe': {
|
|
@@ -14,17 +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('0x0681de31e060b384f0b08a3bac99e9bdff302474');
|
|
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
|
+
accounts: [consts_1.passkeyAccount],
|
|
24
24
|
},
|
|
25
25
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
26
26
|
});
|
|
27
|
-
(0, vitest_1.expect)(address).toEqual('
|
|
27
|
+
(0, vitest_1.expect)(address).toEqual('0x894b88c04b4de6abddce81e8bdc91927e37d6ced');
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
30
|
(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":"index.test.d.ts","sourceRoot":"","sources":["../../../../accounts/json-rpc/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chains_1 = require("viem/chains");
|
|
4
|
+
const vitest_1 = require("vitest");
|
|
5
|
+
const index_1 = require("./index");
|
|
6
|
+
(0, vitest_1.describe)('JSON-RPC', () => {
|
|
7
|
+
(0, vitest_1.describe)('createTransport', () => {
|
|
8
|
+
(0, vitest_1.test)('Alchemy', () => {
|
|
9
|
+
const transport = (0, index_1.createTransport)(chains_1.base, {
|
|
10
|
+
type: 'alchemy',
|
|
11
|
+
apiKey: '123',
|
|
12
|
+
});
|
|
13
|
+
(0, vitest_1.expect)(transport).toBeDefined();
|
|
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,CAStE;AAED,OAAO,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAlchemyUrl = getAlchemyUrl;
|
|
4
|
+
const shared_configs_1 = require("@rhinestone/shared-configs");
|
|
5
|
+
function getAlchemyUrl(chainId, apiKey) {
|
|
6
|
+
const urlTemplate = shared_configs_1.providers.Alchemy.url_template;
|
|
7
|
+
const chainParam = shared_configs_1.providers.Alchemy.chain_mapping[chainId];
|
|
8
|
+
if (!chainParam) {
|
|
9
|
+
throw new Error(`Unsupported chain: ${chainId}`);
|
|
10
|
+
}
|
|
11
|
+
return urlTemplate
|
|
12
|
+
.replace('{{chain_param}}', chainParam)
|
|
13
|
+
.replace('\$\{ALCHEMY_API_KEY\}', apiKey);
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.test.d.ts","sourceRoot":"","sources":["../../../../accounts/json-rpc/providers.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chains_1 = require("viem/chains");
|
|
4
|
+
const vitest_1 = require("vitest");
|
|
5
|
+
const providers_1 = require("./providers");
|
|
6
|
+
(0, vitest_1.describe)('Providers', () => {
|
|
7
|
+
(0, vitest_1.describe)('Alchemy', () => {
|
|
8
|
+
(0, vitest_1.test)('Network', () => {
|
|
9
|
+
const mockApiKey = '123';
|
|
10
|
+
(0, vitest_1.expect)((0, providers_1.getAlchemyUrl)(chains_1.mainnet.id, mockApiKey)).toBe('https://eth-mainnet.g.alchemy.com/v2/123');
|
|
11
|
+
(0, vitest_1.expect)((0, providers_1.getAlchemyUrl)(chains_1.sepolia.id, mockApiKey)).toBe('https://eth-sepolia.g.alchemy.com/v2/123');
|
|
12
|
+
(0, vitest_1.expect)((0, providers_1.getAlchemyUrl)(chains_1.polygon.id, mockApiKey)).toBe('https://polygon-mainnet.g.alchemy.com/v2/123');
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -16,24 +16,24 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
16
16
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
17
17
|
});
|
|
18
18
|
(0, vitest_1.expect)(factory).toEqual('0xd703aae79538628d27099b8c4f621be4ccd142d5');
|
|
19
|
-
(0, vitest_1.expect)(factoryData).toEqual('
|
|
19
|
+
(0, vitest_1.expect)(factoryData).toEqual('0xc5265d5d0000000000000000000000002577507b78c2008ff367261cb6285d44ba5ef2e90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003243c3b752b01000000000013fdB5234E4E3162a810F54d9f7E980000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000094000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
20
20
|
(0, vitest_1.expect)(salt).toEqual('0x0000000000000000000000000000000000000000000000000000000000000000');
|
|
21
21
|
(0, vitest_1.expect)(implementation).toEqual('0xd6CEDDe84be40893d153Be9d467CD6aD37875b28');
|
|
22
|
-
(0, vitest_1.expect)(initializationCallData).toEqual('
|
|
22
|
+
(0, vitest_1.expect)(initializationCallData).toEqual('0x3c3b752b01000000000013fdB5234E4E3162a810F54d9f7E980000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
23
23
|
});
|
|
24
24
|
(0, vitest_1.test)('Passkey owner', () => {
|
|
25
25
|
const { factory, factoryData, salt, implementation, initializationCallData, } = (0, kernel_1.getDeployArgs)({
|
|
26
26
|
owners: {
|
|
27
27
|
type: 'passkey',
|
|
28
|
-
|
|
28
|
+
accounts: [consts_1.passkeyAccount],
|
|
29
29
|
},
|
|
30
30
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
31
31
|
});
|
|
32
32
|
(0, vitest_1.expect)(factory).toEqual('0xd703aae79538628d27099b8c4f621be4ccd142d5');
|
|
33
|
-
(0, vitest_1.expect)(factoryData).toEqual('
|
|
33
|
+
(0, vitest_1.expect)(factoryData).toEqual('0xc5265d5d0000000000000000000000002577507b78c2008ff367261cb6285d44ba5ef2e90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003443c3b752b010000000000578c4cB0e472a5462da43C495C3F330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000094000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
34
34
|
(0, vitest_1.expect)(salt).toEqual('0x0000000000000000000000000000000000000000000000000000000000000000');
|
|
35
35
|
(0, vitest_1.expect)(implementation).toEqual('0xd6CEDDe84be40893d153Be9d467CD6aD37875b28');
|
|
36
|
-
(0, vitest_1.expect)(initializationCallData).toEqual('
|
|
36
|
+
(0, vitest_1.expect)(initializationCallData).toEqual('0x3c3b752b010000000000578c4cB0e472a5462da43C495C3F330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
39
|
(0, vitest_1.describe)('Get Address', () => {
|
|
@@ -45,17 +45,17 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
45
45
|
},
|
|
46
46
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
47
47
|
});
|
|
48
|
-
(0, vitest_1.expect)(address).toEqual('
|
|
48
|
+
(0, vitest_1.expect)(address).toEqual('0xC3733a544f5246a25405c7446e4D0C6b5762B22e');
|
|
49
49
|
});
|
|
50
50
|
(0, vitest_1.test)('Passkey owner', () => {
|
|
51
51
|
const address = (0, kernel_1.getAddress)({
|
|
52
52
|
owners: {
|
|
53
53
|
type: 'passkey',
|
|
54
|
-
|
|
54
|
+
accounts: [consts_1.passkeyAccount],
|
|
55
55
|
},
|
|
56
56
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
57
57
|
});
|
|
58
|
-
(0, vitest_1.expect)(address).toEqual('
|
|
58
|
+
(0, vitest_1.expect)(address).toEqual('0xE48268B1C69528366d8eFaC5DB6fA947a7B52E55');
|
|
59
59
|
});
|
|
60
60
|
});
|
|
61
61
|
(0, vitest_1.describe)('Get Install Data', () => {
|
|
@@ -3,7 +3,6 @@ import { type SmartAccount, type SmartAccountImplementation } from 'viem/account
|
|
|
3
3
|
import type { Module } from '../modules/common';
|
|
4
4
|
import type { EnableSessionData } from '../modules/validators/smart-sessions';
|
|
5
5
|
import type { OwnerSet, RhinestoneAccountConfig, Session } from '../types';
|
|
6
|
-
import type { Chain } from 'viem';
|
|
7
6
|
import { type ValidatorConfig } from './utils';
|
|
8
7
|
declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
9
8
|
factory: `0x${string}`;
|
|
@@ -15,7 +14,7 @@ declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
|
15
14
|
};
|
|
16
15
|
declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
|
|
17
16
|
declare function getInstallData(module: Module): `0x${string}`;
|
|
18
|
-
declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex, defaultValidatorAddress?: Address
|
|
17
|
+
declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex, defaultValidatorAddress?: Address): Promise<`0x${string}`>;
|
|
19
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">>>;
|
|
20
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">>>;
|
|
21
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">>>;
|
|
@@ -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;AAapE,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAEhC,MAAM,0BAA0B,CAAA;AAGjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,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;AAapE,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;;;;;;;EA6FrD;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"}
|
|
@@ -14,22 +14,52 @@ const account_abstraction_1 = require("viem/account-abstraction");
|
|
|
14
14
|
const modules_1 = require("../modules");
|
|
15
15
|
const validators_1 = require("../modules/validators");
|
|
16
16
|
const core_1 = require("../modules/validators/core");
|
|
17
|
-
const modules_2 = require("../modules");
|
|
18
17
|
const error_1 = require("./error");
|
|
19
18
|
const utils_1 = require("./utils");
|
|
20
|
-
// On-chain Nexus default validator is Ownable. Using this here ensures
|
|
21
|
-
// we don't compress WebAuthn to zeroAddress in nonce/signature packing.
|
|
22
19
|
const NEXUS_DEFAULT_VALIDATOR_ADDRESS = core_1.OWNABLE_VALIDATOR_ADDRESS;
|
|
23
|
-
const NEXUS_IMPLEMENTATION_ADDRESS = '
|
|
24
|
-
const NEXUS_FACTORY_ADDRESS = '
|
|
25
|
-
const NEXUS_BOOTSTRAP_ADDRESS = '
|
|
20
|
+
const NEXUS_IMPLEMENTATION_ADDRESS = '0x000000000032dDC454C3BDcba80484Ad5A798705';
|
|
21
|
+
const NEXUS_FACTORY_ADDRESS = '0x0000000000679A258c64d2F20F310e12B64b7375';
|
|
22
|
+
const NEXUS_BOOTSTRAP_ADDRESS = '0x00000000006eFb61D8c9546FF1B500de3f244EA7';
|
|
26
23
|
const NEXUS_CREATION_CODE = '0x60806040526102aa803803806100148161018c565b92833981016040828203126101885781516001600160a01b03811692909190838303610188576020810151906001600160401b03821161018857019281601f8501121561018857835161006e610069826101c5565b61018c565b9481865260208601936020838301011161018857815f926020809301865e8601015260017f90b772c2cb8a51aa7a8a65fc23543c6d022d5b3f8e2b92eed79fba7eef8293005d823b15610176577f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b031916821790557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b5f80a282511561015e575f8091610146945190845af43d15610156573d91610137610069846101c5565b9283523d5f602085013e6101e0565b505b604051606b908161023f8239f35b6060916101e0565b50505034156101485763b398979f60e01b5f5260045ffd5b634c9c8ce360e01b5f5260045260245ffd5b5f80fd5b6040519190601f01601f191682016001600160401b038111838210176101b157604052565b634e487b7160e01b5f52604160045260245ffd5b6001600160401b0381116101b157601f01601f191660200190565b9061020457508051156101f557805190602001fd5b63d6bda27560e01b5f5260045ffd5b81511580610235575b610215575090565b639996b31560e01b5f9081526001600160a01b0391909116600452602490fd5b50803b1561020d56fe60806040523615605c575f8073ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416368280378136915af43d5f803e156058573d5ff35b3d5ffd5b00fea164736f6c634300081b000a';
|
|
27
24
|
function getDeployArgs(config) {
|
|
28
25
|
const salt = (0, viem_1.keccak256)('0x');
|
|
29
26
|
const moduleSetup = (0, modules_1.getSetup)(config);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
+
const validators = moduleSetup.validators.filter((v) => v.address !== NEXUS_DEFAULT_VALIDATOR_ADDRESS);
|
|
33
|
+
const bootstrapData = (0, viem_1.size)(defaultValidatorInitData)
|
|
34
|
+
? (0, viem_1.encodeFunctionData)({
|
|
35
|
+
abi: (0, viem_1.parseAbi)([
|
|
36
|
+
'struct BootstrapConfig {address module;bytes initData;}',
|
|
37
|
+
'struct BootstrapPreValidationHookConfig {uint256 hookType;address module;bytes data;}',
|
|
38
|
+
'function initNexusWithDefaultValidatorAndOtherModulesNoRegistry(bytes calldata defaultValidatorInitData,BootstrapConfig[] calldata validators,BootstrapConfig[] calldata executors,BootstrapConfig calldata hook,BootstrapConfig[] calldata fallbacks,BootstrapPreValidationHookConfig[] calldata preValidationHooks) external',
|
|
39
|
+
]),
|
|
40
|
+
functionName: 'initNexusWithDefaultValidatorAndOtherModulesNoRegistry',
|
|
41
|
+
args: [
|
|
42
|
+
defaultValidatorInitData,
|
|
43
|
+
validators.map((v) => ({
|
|
44
|
+
module: v.address,
|
|
45
|
+
initData: v.initData,
|
|
46
|
+
})),
|
|
47
|
+
moduleSetup.executors.map((e) => ({
|
|
48
|
+
module: e.address,
|
|
49
|
+
initData: e.initData,
|
|
50
|
+
})),
|
|
51
|
+
{
|
|
52
|
+
module: viem_1.zeroAddress,
|
|
53
|
+
initData: '0x',
|
|
54
|
+
},
|
|
55
|
+
moduleSetup.fallbacks.map((f) => ({
|
|
56
|
+
module: f.address,
|
|
57
|
+
initData: f.initData,
|
|
58
|
+
})),
|
|
59
|
+
[],
|
|
60
|
+
],
|
|
61
|
+
})
|
|
62
|
+
: (0, viem_1.encodeFunctionData)({
|
|
33
63
|
abi: (0, viem_1.parseAbi)([
|
|
34
64
|
'struct BootstrapConfig {address module;bytes initData;}',
|
|
35
65
|
'struct BootstrapPreValidationHookConfig {uint256 hookType;address module;bytes data;}',
|
|
@@ -37,7 +67,7 @@ function getDeployArgs(config) {
|
|
|
37
67
|
]),
|
|
38
68
|
functionName: 'initNexusNoRegistry',
|
|
39
69
|
args: [
|
|
40
|
-
|
|
70
|
+
validators.map((v) => ({
|
|
41
71
|
module: v.address,
|
|
42
72
|
initData: v.initData,
|
|
43
73
|
})),
|
|
@@ -55,8 +85,8 @@ function getDeployArgs(config) {
|
|
|
55
85
|
})),
|
|
56
86
|
[],
|
|
57
87
|
],
|
|
58
|
-
})
|
|
59
|
-
]);
|
|
88
|
+
});
|
|
89
|
+
const initData = (0, viem_1.encodeAbiParameters)([{ type: 'address' }, { type: 'bytes' }], [NEXUS_BOOTSTRAP_ADDRESS, bootstrapData]);
|
|
60
90
|
const factoryData = (0, viem_1.encodeFunctionData)({
|
|
61
91
|
abi: (0, viem_1.parseAbi)(['function createAccount(bytes,bytes32)']),
|
|
62
92
|
functionName: 'createAccount',
|
|
@@ -121,70 +151,10 @@ function getInstallData(module) {
|
|
|
121
151
|
args: [module.type, module.address, module.initData],
|
|
122
152
|
});
|
|
123
153
|
}
|
|
124
|
-
function
|
|
125
|
-
// Get the account address
|
|
126
|
-
const accountAddress = getAddress(config);
|
|
127
|
-
// Extract pubKey from config - for passkey owners
|
|
128
|
-
if (config.owners.type !== 'passkey') {
|
|
129
|
-
throw new Error('WebAuthn validator can only be used with passkey owners');
|
|
130
|
-
}
|
|
131
|
-
const { x: pubKeyX, y: pubKeyY } = (0, core_1.parsePublicKey)(config.owners.account.publicKey);
|
|
132
|
-
// Generate credential ID using the same logic as the contract
|
|
133
|
-
const credentialId = (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([
|
|
134
|
-
{ type: 'uint256', name: 'pubKeyX' },
|
|
135
|
-
{ type: 'uint256', name: 'pubKeyY' },
|
|
136
|
-
{ type: 'address', name: 'account' },
|
|
137
|
-
], [pubKeyX, pubKeyY, accountAddress]));
|
|
138
|
-
// Determine usePrecompile based on chain support
|
|
139
|
-
const usePrecompile = (0, modules_2.isRip7212SupportedNetwork)(chain);
|
|
140
|
-
// Decode the WebAuthnAuth struct that was encoded by getWebauthnValidatorSignature
|
|
141
|
-
const decodedAuth = (0, viem_1.decodeAbiParameters)([
|
|
142
|
-
{
|
|
143
|
-
components: [
|
|
144
|
-
{ type: 'bytes', name: 'authenticatorData' },
|
|
145
|
-
{ type: 'string', name: 'clientDataJSON' },
|
|
146
|
-
{ type: 'uint256', name: 'challengeIndex' },
|
|
147
|
-
{ type: 'uint256', name: 'typeIndex' },
|
|
148
|
-
{ type: 'uint256', name: 'r' },
|
|
149
|
-
{ type: 'uint256', name: 's' },
|
|
150
|
-
],
|
|
151
|
-
type: 'tuple',
|
|
152
|
-
name: 'auth',
|
|
153
|
-
},
|
|
154
|
-
], encodedWebAuthnAuth)[0];
|
|
155
|
-
// Build the payload expected by WebAuthnValidator._validateSignatureWithConfig
|
|
156
|
-
// Format: abi.encode(bytes32[] credIds, bool usePrecompile, WebAuthn.WebAuthnAuth[] auth)
|
|
157
|
-
return (0, viem_1.encodeAbiParameters)([
|
|
158
|
-
{ type: 'bytes32[]', name: 'credIds' },
|
|
159
|
-
{ type: 'bool', name: 'usePrecompile' },
|
|
160
|
-
{
|
|
161
|
-
components: [
|
|
162
|
-
{ type: 'bytes', name: 'authenticatorData' },
|
|
163
|
-
{ type: 'string', name: 'clientDataJSON' },
|
|
164
|
-
{ type: 'uint256', name: 'challengeIndex' },
|
|
165
|
-
{ type: 'uint256', name: 'typeIndex' },
|
|
166
|
-
{ type: 'uint256', name: 'r' },
|
|
167
|
-
{ type: 'uint256', name: 's' },
|
|
168
|
-
],
|
|
169
|
-
type: 'tuple[]',
|
|
170
|
-
name: 'auth',
|
|
171
|
-
},
|
|
172
|
-
], [
|
|
173
|
-
[credentialId], // Single credential ID in array
|
|
174
|
-
usePrecompile,
|
|
175
|
-
[decodedAuth], // Single WebAuthnAuth in array
|
|
176
|
-
]);
|
|
177
|
-
}
|
|
178
|
-
async function packSignature(signature, validator, transformSignature = (signature) => signature, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS, config, chain) {
|
|
154
|
+
async function packSignature(signature, validator, transformSignature = (signature) => signature, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
|
|
179
155
|
const validatorAddress = validator.address === defaultValidatorAddress
|
|
180
156
|
? viem_1.zeroAddress
|
|
181
157
|
: validator.address;
|
|
182
|
-
// Special handling for WebAuthn validator
|
|
183
|
-
if (validator.address === core_1.WEBAUTHN_VALIDATOR_ADDRESS && config && chain) {
|
|
184
|
-
const webAuthnPayload = buildWebAuthnValidatorPayload(signature, config, chain);
|
|
185
|
-
const packedSig = (0, viem_1.encodePacked)(['address', 'bytes'], [validatorAddress, transformSignature(webAuthnPayload)]);
|
|
186
|
-
return packedSig;
|
|
187
|
-
}
|
|
188
158
|
const packedSig = (0, viem_1.encodePacked)(['address', 'bytes'], [validatorAddress, transformSignature(signature)]);
|
|
189
159
|
return packedSig;
|
|
190
160
|
}
|