@rhinestone/sdk 1.0.0-alpha.25 → 1.0.0-alpha.26
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 +10 -3
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +114 -36
- package/dist/src/accounts/index.test.js +2 -2
- 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 +28 -1
- package/dist/src/accounts/kernel.test.js +37 -4
- 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 +35 -2
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +78 -55
- package/dist/src/accounts/safe.test.js +35 -2
- package/dist/src/accounts/signing/common.d.ts +1 -1
- package/dist/src/accounts/signing/common.d.ts.map +1 -1
- package/dist/src/accounts/signing/common.js +14 -13
- package/dist/src/accounts/signing/message.js +3 -3
- 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/actions/index.d.ts +1 -1
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +3 -6
- package/dist/src/actions/index.test.js +11 -11
- package/dist/src/execution/index.d.ts +11 -2
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +23 -16
- 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 +23 -5
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +12 -0
- package/dist/src/modules/index.d.ts +2 -1
- 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 +3 -3
- package/dist/src/modules/validators/core.d.ts +4 -3
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +24 -14
- package/dist/src/modules/validators/core.test.js +4 -4
- package/dist/src/types.d.ts +30 -20
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/src/accounts/custom.d.ts +0 -18
- package/dist/src/accounts/custom.d.ts.map +0 -1
- package/dist/src/accounts/custom.js +0 -121
- package/dist/src/accounts/custom.test.d.ts +0 -2
- package/dist/src/accounts/custom.test.d.ts.map +0 -1
- package/dist/src/accounts/custom.test.js +0 -64
|
@@ -5,6 +5,11 @@ import type { AccountProviderConfig, Call, OwnerSet, RhinestoneAccountConfig, Se
|
|
|
5
5
|
import { AccountError, Eip7702AccountMustHaveEoaError, Eip7702NotSupportedForAccountError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, isAccountError, SigningNotSupportedForAccountError, SignMessageNotSupportedByAccountError, SmartSessionsNotEnabledError } from './error';
|
|
6
6
|
import { type ValidatorConfig } from './utils';
|
|
7
7
|
declare function getInitCode(config: RhinestoneAccountConfig): {
|
|
8
|
+
address: import("viem").Address;
|
|
9
|
+
factory: import("viem").Address;
|
|
10
|
+
factoryData: Hex;
|
|
11
|
+
intentExecutorInstalled: boolean;
|
|
12
|
+
} | {
|
|
8
13
|
factory: `0x${string}`;
|
|
9
14
|
factoryData: `0x${string}`;
|
|
10
15
|
} | undefined;
|
|
@@ -16,14 +21,16 @@ declare function getEip7702InitCall(config: RhinestoneAccountConfig, signature:
|
|
|
16
21
|
declare function getModuleInstallationCalls(config: RhinestoneAccountConfig, module: Module): Call[];
|
|
17
22
|
declare function getModuleUninstallationCalls(config: RhinestoneAccountConfig, module: Module): Call[];
|
|
18
23
|
declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
|
|
24
|
+
declare function checkAddress(config: RhinestoneAccountConfig): boolean;
|
|
19
25
|
declare function getPackedSignature(config: RhinestoneAccountConfig, signers: SignerSet | undefined, chain: Chain, validator: ValidatorConfig, hash: Hex, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
|
|
20
26
|
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
27
|
declare function isDeployed(config: RhinestoneAccountConfig, chain: Chain): Promise<boolean>;
|
|
22
|
-
declare function deploy(config: RhinestoneAccountConfig, chain: Chain, session?: Session): Promise<
|
|
28
|
+
declare function deploy(config: RhinestoneAccountConfig, chain: Chain, session?: Session): Promise<boolean>;
|
|
29
|
+
declare function setup(config: RhinestoneAccountConfig, chain: Chain): Promise<boolean>;
|
|
23
30
|
declare function toErc6492Signature(config: RhinestoneAccountConfig, signature: Hex, chain: Chain): Promise<Hex>;
|
|
24
31
|
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
32
|
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
|
-
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"
|
|
33
|
+
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
34
|
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, };
|
|
35
|
+
export { getModuleInstallationCalls, getModuleUninstallationCalls, getAddress, checkAddress, getAccountProvider, getInitCode, signEip7702InitData, getEip7702InitCall, isDeployed, deploy, setup, toErc6492Signature, getSmartAccount, getSmartSessionSmartAccount, getGuardianSmartAccount, getPackedSignature, getTypedDataPackedSignature, isAccountError, AccountError, Eip7702AccountMustHaveEoaError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, SmartSessionsNotEnabledError, SigningNotSupportedForAccountError, SignMessageNotSupportedByAccountError, Eip7702NotSupportedForAccountError, };
|
|
29
36
|
//# 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,EAKV,KAAK,uBAAuB,EAC5B,KAAK,GAAG,EAER,KAAK,YAAY,EAEjB,KAAK,SAAS,EAEf,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../accounts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,KAAK,EAKV,KAAK,uBAAuB,E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,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,QAAQ,oKAyDpB;AAMD,iBAAS,kBAAkB,CACzB,MAAM,EAAE,uBAAuB,GAC9B,qBAAqB,CAOvB;AAED,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC5B,UAAU,EACV,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,UAAU,EACV,MAAM,EACN,KAAK,EACL,kBAAkB,EAClB,eAAe,EACf,2BAA2B,EAC3B,uBAAuB,EACvB,kBAAkB,EAClB,2BAA2B,EAE3B,cAAc,EACd,YAAY,EACZ,8BAA8B,EAC9B,wCAAwC,EACxC,4BAA4B,EAC5B,4BAA4B,EAC5B,kCAAkC,EAClC,qCAAqC,EACrC,kCAAkC,GACnC,CAAA"}
|
|
@@ -4,12 +4,14 @@ exports.Eip7702NotSupportedForAccountError = exports.SignMessageNotSupportedByAc
|
|
|
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;
|
|
11
12
|
exports.isDeployed = isDeployed;
|
|
12
13
|
exports.deploy = deploy;
|
|
14
|
+
exports.setup = setup;
|
|
13
15
|
exports.toErc6492Signature = toErc6492Signature;
|
|
14
16
|
exports.getSmartAccount = getSmartAccount;
|
|
15
17
|
exports.getSmartSessionSmartAccount = getSmartSessionSmartAccount;
|
|
@@ -19,9 +21,9 @@ exports.getTypedDataPackedSignature = getTypedDataPackedSignature;
|
|
|
19
21
|
const viem_1 = require("viem");
|
|
20
22
|
const execution_1 = require("../execution");
|
|
21
23
|
const smart_session_1 = require("../execution/smart-session");
|
|
24
|
+
const modules_1 = require("../modules");
|
|
22
25
|
const validators_1 = require("../modules/validators");
|
|
23
26
|
const core_1 = require("../modules/validators/core");
|
|
24
|
-
const custom_1 = require("./custom");
|
|
25
27
|
const error_1 = require("./error");
|
|
26
28
|
Object.defineProperty(exports, "AccountError", { enumerable: true, get: function () { return error_1.AccountError; } });
|
|
27
29
|
Object.defineProperty(exports, "Eip7702AccountMustHaveEoaError", { enumerable: true, get: function () { return error_1.Eip7702AccountMustHaveEoaError; } });
|
|
@@ -55,15 +57,15 @@ function getDeployArgs(config) {
|
|
|
55
57
|
case 'startale': {
|
|
56
58
|
return (0, startale_1.getDeployArgs)(config);
|
|
57
59
|
}
|
|
58
|
-
case 'custom': {
|
|
59
|
-
return (0, custom_1.getDeployArgs)(config);
|
|
60
|
-
}
|
|
61
60
|
}
|
|
62
61
|
}
|
|
63
62
|
function getInitCode(config) {
|
|
64
63
|
if (is7702(config)) {
|
|
65
64
|
return undefined;
|
|
66
65
|
}
|
|
66
|
+
else if (config.initData) {
|
|
67
|
+
return config.initData;
|
|
68
|
+
}
|
|
67
69
|
else {
|
|
68
70
|
const { factory, factoryData } = getDeployArgs(config);
|
|
69
71
|
if (!factory || !factoryData) {
|
|
@@ -90,9 +92,6 @@ async function signEip7702InitData(config) {
|
|
|
90
92
|
case 'startale': {
|
|
91
93
|
throw new Error(`7702 is not supported for account type ${account.type}`);
|
|
92
94
|
}
|
|
93
|
-
case 'custom': {
|
|
94
|
-
throw new Error('7702 is not supported for custom account');
|
|
95
|
-
}
|
|
96
95
|
}
|
|
97
96
|
}
|
|
98
97
|
async function getEip7702InitCall(config, signature) {
|
|
@@ -106,9 +105,6 @@ async function getEip7702InitCall(config, signature) {
|
|
|
106
105
|
case 'startale': {
|
|
107
106
|
throw new Error(`7702 is not supported for account type ${account.type}`);
|
|
108
107
|
}
|
|
109
|
-
case 'custom': {
|
|
110
|
-
throw new Error('7702 is not supported for custom account');
|
|
111
|
-
}
|
|
112
108
|
}
|
|
113
109
|
}
|
|
114
110
|
function getModuleInstallationCalls(config, module) {
|
|
@@ -128,9 +124,6 @@ function getModuleInstallationCalls(config, module) {
|
|
|
128
124
|
case 'startale': {
|
|
129
125
|
return [(0, startale_1.getInstallData)(module)];
|
|
130
126
|
}
|
|
131
|
-
case 'custom': {
|
|
132
|
-
return (0, custom_1.getInstallData)(config, module);
|
|
133
|
-
}
|
|
134
127
|
}
|
|
135
128
|
}
|
|
136
129
|
const installData = getInstallData();
|
|
@@ -191,11 +184,14 @@ function getAddress(config) {
|
|
|
191
184
|
case 'startale': {
|
|
192
185
|
return (0, startale_1.getAddress)(config);
|
|
193
186
|
}
|
|
194
|
-
case 'custom': {
|
|
195
|
-
return (0, custom_1.getAddress)(config);
|
|
196
|
-
}
|
|
197
187
|
}
|
|
198
188
|
}
|
|
189
|
+
function checkAddress(config) {
|
|
190
|
+
if (!config.initData) {
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
return (config.initData.address.toLowerCase() === getAddress(config).toLowerCase());
|
|
194
|
+
}
|
|
199
195
|
// Signs and packs a signature to be EIP-1271 compatible
|
|
200
196
|
async function getPackedSignature(config, signers, chain, validator, hash, transformSignature = (signature) => signature) {
|
|
201
197
|
signers = signers ?? (0, common_1.convertOwnerSetToSignerSet)(config.owners);
|
|
@@ -209,7 +205,8 @@ async function getPackedSignature(config, signers, chain, validator, hash, trans
|
|
|
209
205
|
}
|
|
210
206
|
case 'nexus': {
|
|
211
207
|
const signature = await signFn(hash);
|
|
212
|
-
|
|
208
|
+
const defaultValidatorAddress = (0, nexus_1.getDefaultValidatorAddress)(account.version);
|
|
209
|
+
return (0, nexus_1.packSignature)(signature, validator, transformSignature, defaultValidatorAddress);
|
|
213
210
|
}
|
|
214
211
|
case 'kernel': {
|
|
215
212
|
const signature = await signFn((0, kernel_1.wrapMessageHash)(hash, address));
|
|
@@ -219,10 +216,6 @@ async function getPackedSignature(config, signers, chain, validator, hash, trans
|
|
|
219
216
|
const signature = await signFn(hash);
|
|
220
217
|
return (0, startale_1.packSignature)(signature, validator, transformSignature);
|
|
221
218
|
}
|
|
222
|
-
case 'custom': {
|
|
223
|
-
const signature = await signFn(hash);
|
|
224
|
-
return (0, custom_1.getPackedSignature)(config, signature, validator, transformSignature);
|
|
225
|
-
}
|
|
226
219
|
}
|
|
227
220
|
}
|
|
228
221
|
// Signs and packs a signature to be EIP-1271 compatible
|
|
@@ -236,13 +229,10 @@ async function getTypedDataPackedSignature(config, signers, chain, validator, pa
|
|
|
236
229
|
const signature = await signFn(parameters);
|
|
237
230
|
return (0, safe_1.packSignature)(signature, validator, transformSignature);
|
|
238
231
|
}
|
|
239
|
-
case 'custom': {
|
|
240
|
-
const signature = await signFn(parameters);
|
|
241
|
-
return (0, custom_1.getPackedSignature)(config, signature, validator, transformSignature);
|
|
242
|
-
}
|
|
243
232
|
case 'nexus': {
|
|
244
233
|
const signature = await signFn(parameters);
|
|
245
|
-
|
|
234
|
+
const defaultValidatorAddress = (0, nexus_1.getDefaultValidatorAddress)(account.version);
|
|
235
|
+
return (0, nexus_1.packSignature)(signature, validator, transformSignature, defaultValidatorAddress);
|
|
246
236
|
}
|
|
247
237
|
case 'kernel': {
|
|
248
238
|
const address = getAddress(config);
|
|
@@ -275,10 +265,77 @@ async function isDeployed(config, chain) {
|
|
|
275
265
|
return (0, viem_1.size)(code) > 0;
|
|
276
266
|
}
|
|
277
267
|
async function deploy(config, chain, session) {
|
|
278
|
-
await
|
|
268
|
+
const deployed = await isDeployed(config, chain);
|
|
269
|
+
if (deployed) {
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
const asUserOp = config.initData && !config.initData.intentExecutorInstalled;
|
|
273
|
+
if (asUserOp) {
|
|
274
|
+
await deployWithBundler(chain, config);
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
await deployWithIntent(chain, config);
|
|
278
|
+
}
|
|
279
279
|
if (session) {
|
|
280
280
|
await (0, smart_session_1.enableSmartSession)(chain, config, session);
|
|
281
281
|
}
|
|
282
|
+
return true;
|
|
283
|
+
}
|
|
284
|
+
// Installs the missing modules
|
|
285
|
+
// Checks if the provided modules are already installed
|
|
286
|
+
// Useful for existing (already deployed) accounts
|
|
287
|
+
async function setup(config, chain) {
|
|
288
|
+
const modules = (0, modules_1.getSetup)(config);
|
|
289
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
290
|
+
chain,
|
|
291
|
+
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
292
|
+
});
|
|
293
|
+
const address = getAddress(config);
|
|
294
|
+
const allModules = [
|
|
295
|
+
...modules.validators,
|
|
296
|
+
...modules.executors,
|
|
297
|
+
...modules.fallbacks,
|
|
298
|
+
...modules.hooks,
|
|
299
|
+
];
|
|
300
|
+
// Check if the modules are already installed
|
|
301
|
+
const installedResults = await publicClient.multicall({
|
|
302
|
+
contracts: allModules.map((module) => ({
|
|
303
|
+
address: address,
|
|
304
|
+
abi: [
|
|
305
|
+
{
|
|
306
|
+
type: 'function',
|
|
307
|
+
name: 'isModuleInstalled',
|
|
308
|
+
inputs: [
|
|
309
|
+
{ type: 'uint256', name: 'moduleTypeId' },
|
|
310
|
+
{ type: 'address', name: 'module' },
|
|
311
|
+
{ type: 'bytes', name: 'additionalContext' },
|
|
312
|
+
],
|
|
313
|
+
outputs: [{ type: 'bool', name: 'isInstalled' }],
|
|
314
|
+
stateMutability: 'view',
|
|
315
|
+
},
|
|
316
|
+
],
|
|
317
|
+
functionName: 'isModuleInstalled',
|
|
318
|
+
args: [module.type, module.address, module.additionalContext],
|
|
319
|
+
})),
|
|
320
|
+
});
|
|
321
|
+
const isInstalled = installedResults.map((result) => result.result);
|
|
322
|
+
const modulesToInstall = allModules.filter((_, index) => !isInstalled[index]);
|
|
323
|
+
if (modulesToInstall.length === 0) {
|
|
324
|
+
// Nothing to install
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
327
|
+
const calls = [];
|
|
328
|
+
for (const module of modulesToInstall) {
|
|
329
|
+
calls.push(...getModuleInstallationCalls(config, module));
|
|
330
|
+
}
|
|
331
|
+
// Select the transaction infra layer based on the intent executor status
|
|
332
|
+
const intentExecutor = (0, modules_1.getIntentExecutor)(config);
|
|
333
|
+
const hasIntentExecutor = modulesToInstall.every((module) => module.address !== intentExecutor.address);
|
|
334
|
+
const result = await (0, execution_1.sendTransactionInternal)(config, [chain], chain, calls, {
|
|
335
|
+
asUserOp: !hasIntentExecutor,
|
|
336
|
+
});
|
|
337
|
+
await (0, execution_1.waitForExecution)(config, result, true);
|
|
338
|
+
return true;
|
|
282
339
|
}
|
|
283
340
|
async function deployWithIntent(chain, config) {
|
|
284
341
|
const publicClient = (0, viem_1.createPublicClient)({
|
|
@@ -302,6 +359,30 @@ async function deployWithIntent(chain, config) {
|
|
|
302
359
|
});
|
|
303
360
|
await (0, execution_1.waitForExecution)(config, result, true);
|
|
304
361
|
}
|
|
362
|
+
async function deployWithBundler(chain, config) {
|
|
363
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
364
|
+
chain,
|
|
365
|
+
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
366
|
+
});
|
|
367
|
+
const bundlerClient = (0, utils_1.getBundlerClient)(config, publicClient);
|
|
368
|
+
const smartAccount = await getSmartAccount(config, publicClient, chain);
|
|
369
|
+
const { factory, factoryData } = getDeployArgs(config);
|
|
370
|
+
const opHash = await bundlerClient.sendUserOperation({
|
|
371
|
+
account: smartAccount,
|
|
372
|
+
factory,
|
|
373
|
+
factoryData,
|
|
374
|
+
calls: [
|
|
375
|
+
{
|
|
376
|
+
to: viem_1.zeroAddress,
|
|
377
|
+
value: 0n,
|
|
378
|
+
data: '0x',
|
|
379
|
+
},
|
|
380
|
+
],
|
|
381
|
+
});
|
|
382
|
+
await bundlerClient.waitForUserOperationReceipt({
|
|
383
|
+
hash: opHash,
|
|
384
|
+
});
|
|
385
|
+
}
|
|
305
386
|
async function toErc6492Signature(config, signature, chain) {
|
|
306
387
|
const deployed = await isDeployed(config, chain);
|
|
307
388
|
if (deployed) {
|
|
@@ -334,7 +415,8 @@ async function getSmartAccount(config, client, chain) {
|
|
|
334
415
|
return (0, safe_1.getSmartAccount)(client, address, config.owners, ownerValidator.address, signFn);
|
|
335
416
|
}
|
|
336
417
|
case 'nexus': {
|
|
337
|
-
|
|
418
|
+
const defaultValidatorAddress = (0, nexus_1.getDefaultValidatorAddress)(account.version);
|
|
419
|
+
return (0, nexus_1.getSmartAccount)(client, address, config.owners, ownerValidator.address, signFn, defaultValidatorAddress);
|
|
338
420
|
}
|
|
339
421
|
case 'kernel': {
|
|
340
422
|
return (0, kernel_1.getSmartAccount)(client, address, config.owners, ownerValidator.address, signFn);
|
|
@@ -342,9 +424,6 @@ async function getSmartAccount(config, client, chain) {
|
|
|
342
424
|
case 'startale': {
|
|
343
425
|
return (0, startale_1.getSmartAccount)(client, address, config.owners, ownerValidator.address, signFn);
|
|
344
426
|
}
|
|
345
|
-
case 'custom': {
|
|
346
|
-
return (0, custom_1.getSmartAccount)(config, client, address, ownerValidator.address, signFn);
|
|
347
|
-
}
|
|
348
427
|
}
|
|
349
428
|
}
|
|
350
429
|
async function getSmartSessionSmartAccount(config, client, chain, session, enableData) {
|
|
@@ -365,7 +444,8 @@ async function getSmartSessionSmartAccount(config, client, chain, session, enabl
|
|
|
365
444
|
return (0, safe_1.getSessionSmartAccount)(client, address, session, smartSessionValidator.address, enableData, signFn);
|
|
366
445
|
}
|
|
367
446
|
case 'nexus': {
|
|
368
|
-
|
|
447
|
+
const defaultValidatorAddress = (0, nexus_1.getDefaultValidatorAddress)(account.version);
|
|
448
|
+
return (0, nexus_1.getSessionSmartAccount)(client, address, session, smartSessionValidator.address, enableData, signFn, defaultValidatorAddress);
|
|
369
449
|
}
|
|
370
450
|
case 'kernel': {
|
|
371
451
|
return (0, kernel_1.getSessionSmartAccount)(client, address, session, smartSessionValidator.address, enableData, signFn);
|
|
@@ -373,9 +453,6 @@ async function getSmartSessionSmartAccount(config, client, chain, session, enabl
|
|
|
373
453
|
case 'startale': {
|
|
374
454
|
return (0, startale_1.getSessionSmartAccount)(client, address, session, smartSessionValidator.address, enableData, signFn);
|
|
375
455
|
}
|
|
376
|
-
case 'custom': {
|
|
377
|
-
return (0, custom_1.getSessionSmartAccount)(config, client, address, session, smartSessionValidator.address, enableData);
|
|
378
|
-
}
|
|
379
456
|
}
|
|
380
457
|
}
|
|
381
458
|
async function getGuardianSmartAccount(config, client, chain, guardians) {
|
|
@@ -396,7 +473,8 @@ async function getGuardianSmartAccount(config, client, chain, guardians) {
|
|
|
396
473
|
return (0, safe_1.getGuardianSmartAccount)(client, address, guardians, socialRecoveryValidator.address, signFn);
|
|
397
474
|
}
|
|
398
475
|
case 'nexus': {
|
|
399
|
-
|
|
476
|
+
const defaultValidatorAddress = (0, nexus_1.getDefaultValidatorAddress)(account.version);
|
|
477
|
+
return (0, nexus_1.getGuardianSmartAccount)(client, address, guardians, socialRecoveryValidator.address, signFn, defaultValidatorAddress);
|
|
400
478
|
}
|
|
401
479
|
case 'kernel': {
|
|
402
480
|
return (0, kernel_1.getGuardianSmartAccount)(client, address, guardians, socialRecoveryValidator.address, signFn);
|
|
@@ -14,7 +14,7 @@ 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)({
|
|
@@ -24,7 +24,7 @@ const _1 = require(".");
|
|
|
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', () => {
|
|
@@ -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;AAC1E,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAgBhF,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;EAyErD;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"}
|
|
@@ -16,10 +16,37 @@ const validators_1 = require("../modules/validators");
|
|
|
16
16
|
const utils_1 = require("./utils");
|
|
17
17
|
const KERNEL_META_FACTORY_ADDRESS = '0xd703aae79538628d27099b8c4f621be4ccd142d5';
|
|
18
18
|
const KERNEL_IMPLEMENTATION_ADDRESS = '0xd6CEDDe84be40893d153Be9d467CD6aD37875b28';
|
|
19
|
-
const KERNEL_FACTORY_ADDRESS = '
|
|
19
|
+
const KERNEL_FACTORY_ADDRESS = '0x2577507b78c2008Ff367261CB6285d44ba5eF2E9';
|
|
20
20
|
const KERNEL_BYTECODE = '0x603d3d8160223d3973d6cedde84be40893d153be9d467cd6ad37875b2860095155f3363d3d373d3d363d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc545af43d6000803e6038573d6000fd5b3d6000f3';
|
|
21
21
|
const KERNEL_VERSION = '0.3.3';
|
|
22
22
|
function getDeployArgs(config) {
|
|
23
|
+
if (config.initData) {
|
|
24
|
+
const factoryData = (0, viem_1.decodeFunctionData)({
|
|
25
|
+
abi: (0, viem_1.parseAbi)([
|
|
26
|
+
'function deployWithFactory(address factory,bytes createData,bytes32 salt)',
|
|
27
|
+
]),
|
|
28
|
+
data: config.initData.factoryData,
|
|
29
|
+
});
|
|
30
|
+
if (factoryData.functionName !== 'deployWithFactory') {
|
|
31
|
+
throw new Error('Invalid factory data');
|
|
32
|
+
}
|
|
33
|
+
const factory = factoryData.args[0];
|
|
34
|
+
const createData = factoryData.args[1];
|
|
35
|
+
const salt = factoryData.args[2];
|
|
36
|
+
const implementation = factory === KERNEL_FACTORY_ADDRESS
|
|
37
|
+
? KERNEL_IMPLEMENTATION_ADDRESS
|
|
38
|
+
: viem_1.zeroAddress;
|
|
39
|
+
if (implementation === viem_1.zeroAddress) {
|
|
40
|
+
throw new Error('Unsupported Kernel implementation');
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
factory: config.initData.factory,
|
|
44
|
+
factoryData: config.initData.factoryData,
|
|
45
|
+
implementation,
|
|
46
|
+
initializationCallData: createData,
|
|
47
|
+
salt,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
23
50
|
const salt = viem_1.zeroHash;
|
|
24
51
|
const moduleSetup = (0, modules_1.getSetup)(config);
|
|
25
52
|
const rootValidator = (0, viem_1.concat)(['0x01', moduleSetup.validators[0].address]);
|
|
@@ -16,10 +16,10 @@ 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)({
|
|
@@ -30,10 +30,27 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
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
|
+
});
|
|
38
|
+
(0, vitest_1.test)('Existing account', () => {
|
|
39
|
+
const { factory, factoryData } = (0, kernel_1.getDeployArgs)({
|
|
40
|
+
owners: {
|
|
41
|
+
type: 'ecdsa',
|
|
42
|
+
accounts: [consts_1.accountA, consts_1.accountB],
|
|
43
|
+
},
|
|
44
|
+
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
45
|
+
initData: {
|
|
46
|
+
address: '0x86c4b9c9eA5df80D4e080e285015Cda47A503B51',
|
|
47
|
+
factory: '0xd703aaE79538628d27099B8c4f621bE4CCd142d5',
|
|
48
|
+
factoryData: '0xc5265d5d0000000000000000000000002577507b78c2008ff367261cb6285d44ba5ef2e90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001243c3b752b01845ADb2C711129d4f3966735eD98a9F09fC4cE570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001460098F8D98a9c55F21D17C26c78bF3D71Edc0E740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
|
49
|
+
intentExecutorInstalled: false,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
(0, vitest_1.expect)(factory).toEqual('0xd703aaE79538628d27099B8c4f621bE4CCd142d5');
|
|
53
|
+
(0, vitest_1.expect)(factoryData).toEqual('0xc5265d5d0000000000000000000000002577507b78c2008ff367261cb6285d44ba5ef2e90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001243c3b752b01845ADb2C711129d4f3966735eD98a9F09fC4cE570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001460098F8D98a9c55F21D17C26c78bF3D71Edc0E740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
37
54
|
});
|
|
38
55
|
});
|
|
39
56
|
(0, vitest_1.describe)('Get Address', () => {
|
|
@@ -57,6 +74,22 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
57
74
|
});
|
|
58
75
|
(0, vitest_1.expect)(address).toEqual('0xE48268B1C69528366d8eFaC5DB6fA947a7B52E55');
|
|
59
76
|
});
|
|
77
|
+
(0, vitest_1.test)('Existing account', () => {
|
|
78
|
+
const address = (0, kernel_1.getAddress)({
|
|
79
|
+
owners: {
|
|
80
|
+
type: 'ecdsa',
|
|
81
|
+
accounts: [consts_1.accountA, consts_1.accountB],
|
|
82
|
+
},
|
|
83
|
+
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
84
|
+
initData: {
|
|
85
|
+
address: '0x86c4b9c9eA5df80D4e080e285015Cda47A503B51',
|
|
86
|
+
factory: '0xd703aaE79538628d27099B8c4f621bE4CCd142d5',
|
|
87
|
+
factoryData: '0xc5265d5d0000000000000000000000002577507b78c2008ff367261cb6285d44ba5ef2e90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001243c3b752b01845ADb2C711129d4f3966735eD98a9F09fC4cE570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001460098F8D98a9c55F21D17C26c78bF3D71Edc0E740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
|
88
|
+
intentExecutorInstalled: false,
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
(0, vitest_1.expect)(address).toEqual('0x86c4b9c9eA5df80D4e080e285015Cda47A503B51');
|
|
92
|
+
});
|
|
60
93
|
});
|
|
61
94
|
(0, vitest_1.describe)('Get Install Data', () => {
|
|
62
95
|
(0, vitest_1.test)('Module', () => {
|
|
@@ -5,15 +5,16 @@ import type { EnableSessionData } from '../modules/validators/smart-sessions';
|
|
|
5
5
|
import type { OwnerSet, RhinestoneAccountConfig, Session } from '../types';
|
|
6
6
|
import { type ValidatorConfig } from './utils';
|
|
7
7
|
declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
8
|
+
salt: `0x${string}`;
|
|
8
9
|
factory: `0x${string}`;
|
|
9
10
|
factoryData: `0x${string}`;
|
|
10
|
-
salt: `0x${string}`;
|
|
11
11
|
implementation: `0x${string}`;
|
|
12
|
-
initializationCallData: `0x${string}`;
|
|
13
12
|
initData: `0x${string}`;
|
|
13
|
+
initializationCallData: `0x${string}`;
|
|
14
14
|
};
|
|
15
15
|
declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
|
|
16
16
|
declare function getInstallData(module: Module): `0x${string}`;
|
|
17
|
+
declare function getDefaultValidatorAddress(version: '1.0.2' | '1.2.0' | 'rhinestone-1.0.0-beta' | 'rhinestone-1.0.0' | undefined): Address;
|
|
17
18
|
declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex, defaultValidatorAddress?: Address): Promise<`0x${string}`>;
|
|
18
19
|
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
20
|
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">>>;
|
|
@@ -23,5 +24,5 @@ declare function getEip7702InitCall(config: RhinestoneAccountConfig, signature:
|
|
|
23
24
|
initData: `0x${string}`;
|
|
24
25
|
contract: `0x${string}`;
|
|
25
26
|
}>;
|
|
26
|
-
export { getInstallData, getAddress, packSignature, getDeployArgs, getSmartAccount, getSessionSmartAccount, getGuardianSmartAccount, signEip7702InitData, getEip7702InitCall, };
|
|
27
|
+
export { getInstallData, getAddress, getDefaultValidatorAddress, packSignature, getDeployArgs, getSmartAccount, getSessionSmartAccount, getGuardianSmartAccount, signEip7702InitData, getEip7702InitCall, };
|
|
27
28
|
//# 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;
|
|
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;AAcpE,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;AAoBhF,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;;EAiJrD;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,iBAgClD;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE,MAAM,iBA2BrC;AAED,iBAAS,0BAA0B,CACjC,OAAO,EACH,OAAO,GACP,OAAO,GACP,uBAAuB,GACvB,kBAAkB,GAClB,SAAS,GACZ,OAAO,CAcT;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,EA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