@rhinestone/sdk 0.11.0 → 0.11.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 +5 -2
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +46 -0
- package/dist/src/accounts/kernel.d.ts +4 -1
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +73 -42
- package/dist/src/accounts/kernel.test.js +17 -0
- package/dist/src/accounts/nexus.d.ts +4 -1
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +37 -0
- package/dist/src/accounts/nexus.test.js +14 -0
- package/dist/src/accounts/safe.d.ts +4 -1
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +37 -0
- package/dist/src/accounts/safe.test.js +14 -0
- package/dist/src/actions/index.d.ts +12 -0
- package/dist/src/actions/index.d.ts.map +1 -0
- package/dist/src/actions/index.js +165 -0
- package/dist/src/actions/index.test.d.ts +2 -0
- package/dist/src/actions/index.test.d.ts.map +1 -0
- package/dist/src/actions/index.test.js +170 -0
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +22 -12
- package/dist/src/execution/utils.d.ts +5 -4
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +84 -23
- package/dist/src/index.d.ts +15 -25
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +5 -0
- package/dist/src/modules/validators/core.d.ts +4 -2
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +24 -0
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +1 -0
- package/dist/src/types.d.ts +11 -2
- package/dist/src/types.d.ts.map +1 -1
- package/dist/test/consts.d.ts +2 -1
- package/dist/test/consts.d.ts.map +1 -1
- package/dist/test/consts.js +3 -1
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Chain, type Hex, type PublicClient } from 'viem';
|
|
2
|
-
import
|
|
2
|
+
import { Module } from '../modules/common';
|
|
3
|
+
import type { Call, OwnerSet, RhinestoneAccountConfig, Session } from '../types';
|
|
3
4
|
import { ValidatorConfig } from './utils';
|
|
4
5
|
declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
5
6
|
factory: `0x${string}`;
|
|
@@ -14,6 +15,7 @@ declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
|
14
15
|
implementation: `0x${string}`;
|
|
15
16
|
initializationCallData: `0x${string}`;
|
|
16
17
|
};
|
|
18
|
+
declare function getModuleInstallationCalls(config: RhinestoneAccountConfig, module: Module): Call[];
|
|
17
19
|
declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
|
|
18
20
|
declare function getPackedSignature(config: RhinestoneAccountConfig, owners: OwnerSet, chain: Chain, validator: ValidatorConfig, hash: Hex, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
|
|
19
21
|
declare function isDeployed(chain: Chain, config: RhinestoneAccountConfig): Promise<boolean>;
|
|
@@ -23,6 +25,7 @@ declare function deployTarget(chain: Chain, config: RhinestoneAccountConfig, asU
|
|
|
23
25
|
declare function getBundleInitCode(config: RhinestoneAccountConfig): `0x${string}` | undefined;
|
|
24
26
|
declare function getSmartAccount(config: RhinestoneAccountConfig, client: PublicClient, chain: Chain): Promise<import("viem/account-abstraction").SmartAccount<import("viem/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">>>;
|
|
25
27
|
declare function getSmartSessionSmartAccount(config: RhinestoneAccountConfig, client: PublicClient, chain: Chain, session: Session): Promise<import("viem/account-abstraction").SmartAccount<import("viem/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">>>;
|
|
28
|
+
declare function getGuardianSmartAccount(config: RhinestoneAccountConfig, client: PublicClient, chain: Chain, guardians: OwnerSet): Promise<import("viem/account-abstraction").SmartAccount<import("viem/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">>>;
|
|
26
29
|
declare function sign(validators: OwnerSet, chain: Chain, hash: Hex): Promise<`0x${string}`>;
|
|
27
|
-
export { getDeployArgs, getBundleInitCode, getAddress, isDeployed, deploy, deploySource, deployTarget, getSmartAccount, getSmartSessionSmartAccount, getPackedSignature, sign, };
|
|
30
|
+
export { getModuleInstallationCalls, getDeployArgs, getBundleInitCode, getAddress, isDeployed, deploy, deploySource, deployTarget, getSmartAccount, getSmartSessionSmartAccount, getGuardianSmartAccount, getPackedSignature, sign, };
|
|
28
31
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../accounts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,KAAK,EAKV,KAAK,GAAG,EAER,KAAK,YAAY,EAGlB,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../accounts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,KAAK,EAKV,KAAK,GAAG,EAER,KAAK,YAAY,EAGlB,MAAM,MAAM,CAAA;AAOb,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAM1C,OAAO,KAAK,EAEV,IAAI,EACJ,QAAQ,EACR,uBAAuB,EACvB,OAAO,EACR,MAAM,UAAU,CAAA;AAkCjB,OAAO,EAAoB,eAAe,EAAE,MAAM,SAAS,CAAA;AAE3D,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;;;;;;;EAarD;AAED,iBAAS,0BAA0B,CACjC,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,MAAM,GACb,IAAI,EAAE,CAuBR;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,iBAmBlD;AAGD,iBAAe,kBAAkB,CAC/B,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,QAAQ,EAChB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,eAAe,EAC1B,IAAI,EAAE,GAAG,EACT,kBAAkB,GAAE,CAAC,SAAS,EAAE,GAAG,KAAK,GAA8B,0BA2BvE;AAED,iBAAe,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,uBAAuB,oBAiBtE;AAED,iBAAe,MAAM,CACnB,MAAM,EAAE,uBAAuB,EAC/B,KAAK,EAAE,KAAK,EACZ,OAAO,CAAC,EAAE,OAAO,iBAMlB;AAED,iBAAe,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,uBAAuB,iBAMxE;AAED,iBAAe,YAAY,CACzB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,uBAAuB,EAC/B,QAAQ,EAAE,OAAO,iBASlB;AAUD,iBAAS,iBAAiB,CAAC,MAAM,EAAE,uBAAuB,6BAUzD;AAgID,iBAAe,eAAe,CAC5B,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,KAAK,sJAmCb;AAED,iBAAe,2BAA2B,CACxC,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,sJAuCjB;AAED,iBAAe,uBAAuB,CACpC,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,QAAQ,sJAwCpB;AAED,iBAAe,IAAI,CAAC,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,0BAYhE;AAsED,OAAO,EACL,0BAA0B,EAC1B,aAAa,EACb,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,2BAA2B,EAC3B,uBAAuB,EACvB,kBAAkB,EAClB,IAAI,GACL,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getModuleInstallationCalls = getModuleInstallationCalls;
|
|
3
4
|
exports.getDeployArgs = getDeployArgs;
|
|
4
5
|
exports.getBundleInitCode = getBundleInitCode;
|
|
5
6
|
exports.getAddress = getAddress;
|
|
@@ -9,12 +10,14 @@ exports.deploySource = deploySource;
|
|
|
9
10
|
exports.deployTarget = deployTarget;
|
|
10
11
|
exports.getSmartAccount = getSmartAccount;
|
|
11
12
|
exports.getSmartSessionSmartAccount = getSmartSessionSmartAccount;
|
|
13
|
+
exports.getGuardianSmartAccount = getGuardianSmartAccount;
|
|
12
14
|
exports.getPackedSignature = getPackedSignature;
|
|
13
15
|
exports.sign = sign;
|
|
14
16
|
const viem_1 = require("viem");
|
|
15
17
|
const smart_session_1 = require("../execution/smart-session");
|
|
16
18
|
const modules_1 = require("../modules");
|
|
17
19
|
const validators_1 = require("../modules/validators");
|
|
20
|
+
const core_1 = require("../modules/validators/core");
|
|
18
21
|
const kernel_1 = require("./kernel");
|
|
19
22
|
const nexus_1 = require("./nexus");
|
|
20
23
|
const safe_1 = require("./safe");
|
|
@@ -33,6 +36,28 @@ function getDeployArgs(config) {
|
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
38
|
}
|
|
39
|
+
function getModuleInstallationCalls(config, module) {
|
|
40
|
+
const address = getAddress(config);
|
|
41
|
+
function getInstallData() {
|
|
42
|
+
const account = getAccount(config);
|
|
43
|
+
switch (account.type) {
|
|
44
|
+
case 'safe': {
|
|
45
|
+
return [(0, safe_1.getInstallData)(module)];
|
|
46
|
+
}
|
|
47
|
+
case 'nexus': {
|
|
48
|
+
return [(0, nexus_1.getInstallData)(module)];
|
|
49
|
+
}
|
|
50
|
+
case 'kernel': {
|
|
51
|
+
return (0, kernel_1.getInstallData)(module);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const installData = getInstallData();
|
|
56
|
+
return installData.map((data) => ({
|
|
57
|
+
to: address,
|
|
58
|
+
data,
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
36
61
|
function getAddress(config) {
|
|
37
62
|
if (is7702(config)) {
|
|
38
63
|
if (!config.eoa) {
|
|
@@ -268,6 +293,27 @@ async function getSmartSessionSmartAccount(config, client, chain, session) {
|
|
|
268
293
|
}
|
|
269
294
|
}
|
|
270
295
|
}
|
|
296
|
+
async function getGuardianSmartAccount(config, client, chain, guardians) {
|
|
297
|
+
const address = getAddress(config);
|
|
298
|
+
const accounts = guardians.type === 'ecdsa' ? guardians.accounts : [];
|
|
299
|
+
const socialRecoveryValidator = (0, core_1.getSocialRecoveryValidator)(accounts);
|
|
300
|
+
if (!socialRecoveryValidator) {
|
|
301
|
+
throw new Error('Social recovery is not enabled for this account');
|
|
302
|
+
}
|
|
303
|
+
const signFn = (hash) => sign(guardians, chain, hash);
|
|
304
|
+
const account = getAccount(config);
|
|
305
|
+
switch (account.type) {
|
|
306
|
+
case 'safe': {
|
|
307
|
+
return (0, safe_1.getGuardianSmartAccount)(client, address, guardians, socialRecoveryValidator.address, signFn);
|
|
308
|
+
}
|
|
309
|
+
case 'nexus': {
|
|
310
|
+
return (0, nexus_1.getGuardianSmartAccount)(client, address, guardians, socialRecoveryValidator.address, signFn);
|
|
311
|
+
}
|
|
312
|
+
case 'kernel': {
|
|
313
|
+
return (0, kernel_1.getGuardianSmartAccount)(client, address, guardians, socialRecoveryValidator.address, signFn);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
271
317
|
async function sign(validators, chain, hash) {
|
|
272
318
|
switch (validators.type) {
|
|
273
319
|
case 'ecdsa': {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Abi, Address, Hex, PublicClient } from 'viem';
|
|
2
2
|
import { SmartAccount, SmartAccountImplementation } from 'viem/account-abstraction';
|
|
3
|
+
import { Module } from '../modules/common';
|
|
3
4
|
import { OwnerSet, RhinestoneAccountConfig, Session } from '../types';
|
|
4
5
|
import { ValidatorConfig } from './utils';
|
|
5
6
|
declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
@@ -10,10 +11,12 @@ declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
|
10
11
|
initializationCallData: `0x${string}`;
|
|
11
12
|
};
|
|
12
13
|
declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
|
|
14
|
+
declare function getInstallData(module: Module): Hex[];
|
|
13
15
|
declare function get7702InitCalls(): never;
|
|
14
16
|
declare function get7702SmartAccount(): never;
|
|
15
17
|
declare function getPackedSignature(signFn: (message: Hex) => Promise<Hex>, hash: Hex, validator: ValidatorConfig, accountAddress: Address, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
|
|
16
18
|
declare function getSmartAccount(client: PublicClient, address: Address, owners: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
17
19
|
declare function getSessionSmartAccount(client: PublicClient, address: Address, session: Session, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
18
|
-
|
|
20
|
+
declare function getGuardianSmartAccount(client: PublicClient, address: Address, guardians: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
21
|
+
export { getInstallData, getAddress, getDeployArgs, getSmartAccount, getSessionSmartAccount, getGuardianSmartAccount, get7702InitCalls, get7702SmartAccount, getPackedSignature, };
|
|
19
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,GAAG,EACH,OAAO,EAQP,GAAG,EAEH,YAAY,EAMb,MAAM,MAAM,CAAA;AACb,OAAO,EAIL,YAAY,EACZ,0BAA0B,EAE3B,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../../../accounts/kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,OAAO,EAQP,GAAG,EAEH,YAAY,EAMb,MAAM,MAAM,CAAA;AACb,OAAO,EAIL,YAAY,EACZ,0BAA0B,EAE3B,MAAM,0BAA0B,CAAA;AAGjC,OAAO,EAKL,MAAM,EACP,MAAM,mBAAmB,CAAA;AAO1B,OAAO,EAAE,QAAQ,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,EAAoC,eAAe,EAAE,MAAM,SAAS,CAAA;AAgB3E,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,iBAAS,gBAAgB,IAAI,KAAK,CAEjC;AAED,iBAAS,mBAAmB,IAAI,KAAK,CAEpC;AAED,iBAAe,kBAAkB,CAC/B,MAAM,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,EACtC,IAAI,EAAE,GAAG,EACT,SAAS,EAAE,eAAe,EAC1B,cAAc,EAAE,OAAO,EACvB,kBAAkB,GAAE,CAAC,SAAS,EAAE,GAAG,KAAK,GAA8B,0BAevE;AAwBD,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,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,iEAwBlC;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,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,GACnB,CAAA"}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getInstallData = getInstallData;
|
|
3
4
|
exports.getAddress = getAddress;
|
|
4
5
|
exports.getDeployArgs = getDeployArgs;
|
|
5
6
|
exports.getSmartAccount = getSmartAccount;
|
|
6
7
|
exports.getSessionSmartAccount = getSessionSmartAccount;
|
|
8
|
+
exports.getGuardianSmartAccount = getGuardianSmartAccount;
|
|
7
9
|
exports.get7702InitCalls = get7702InitCalls;
|
|
8
10
|
exports.get7702SmartAccount = get7702SmartAccount;
|
|
9
11
|
exports.getPackedSignature = getPackedSignature;
|
|
10
12
|
const viem_1 = require("viem");
|
|
11
13
|
const account_abstraction_1 = require("viem/account-abstraction");
|
|
12
14
|
const modules_1 = require("../modules");
|
|
15
|
+
const common_1 = require("../modules/common");
|
|
13
16
|
const validators_1 = require("../modules/validators");
|
|
14
17
|
const utils_1 = require("./utils");
|
|
15
18
|
const KERNEL_META_FACTORY_ADDRESS = '0xd703aae79538628d27099b8c4f621be4ccd142d5';
|
|
@@ -24,57 +27,20 @@ function getDeployArgs(config) {
|
|
|
24
27
|
const hook = viem_1.zeroAddress;
|
|
25
28
|
const validatorData = moduleSetup.validators[0].initData;
|
|
26
29
|
const hookData = '0x';
|
|
27
|
-
|
|
30
|
+
// Install modules via init config
|
|
28
31
|
const spareValidators = moduleSetup.validators.slice(1);
|
|
29
32
|
const initConfig = [];
|
|
30
|
-
// Install spare validators
|
|
31
33
|
for (const module of spareValidators) {
|
|
32
|
-
|
|
33
|
-
const initData = (0, viem_1.concat)([hookInstalled, data]);
|
|
34
|
-
initConfig.push((0, viem_1.encodeFunctionData)({
|
|
35
|
-
abi: (0, viem_1.parseAbi)(['function installModule(uint256,address,bytes)']),
|
|
36
|
-
functionName: 'installModule',
|
|
37
|
-
args: [module.type, module.address, initData],
|
|
38
|
-
}));
|
|
39
|
-
const validatorId = (0, viem_1.concat)(['0x01', module.address]);
|
|
40
|
-
initConfig.push((0, viem_1.encodeFunctionData)({
|
|
41
|
-
abi: (0, viem_1.parseAbi)(['function grantAccess(bytes21,bytes4,bool)']),
|
|
42
|
-
functionName: 'grantAccess',
|
|
43
|
-
args: [validatorId, '0xe9ae5c53', true],
|
|
44
|
-
}));
|
|
34
|
+
initConfig.push(...getInstallData(module));
|
|
45
35
|
}
|
|
46
|
-
// Install executors
|
|
47
36
|
for (const module of moduleSetup.executors) {
|
|
48
|
-
|
|
49
|
-
const initData = (0, viem_1.concat)([viem_1.zeroAddress, data]);
|
|
50
|
-
initConfig.push((0, viem_1.encodeFunctionData)({
|
|
51
|
-
abi: (0, viem_1.parseAbi)(['function installModule(uint256,address,bytes)']),
|
|
52
|
-
functionName: 'installModule',
|
|
53
|
-
args: [module.type, module.address, initData],
|
|
54
|
-
}));
|
|
37
|
+
initConfig.push(...getInstallData(module));
|
|
55
38
|
}
|
|
56
|
-
// Install fallbacks
|
|
57
39
|
for (const module of moduleSetup.fallbacks) {
|
|
58
|
-
|
|
59
|
-
{ name: 'selector', type: 'bytes4' },
|
|
60
|
-
{ name: 'flags', type: 'bytes1' },
|
|
61
|
-
{ name: 'data', type: 'bytes' },
|
|
62
|
-
], module.initData);
|
|
63
|
-
const data = (0, viem_1.encodeAbiParameters)([{ type: 'bytes' }, { type: 'bytes' }], [(0, viem_1.concat)([flags, selectorData]), '0x']);
|
|
64
|
-
const initData = (0, viem_1.concat)([selector, hookInstalled, data]);
|
|
65
|
-
initConfig.push((0, viem_1.encodeFunctionData)({
|
|
66
|
-
abi: (0, viem_1.parseAbi)(['function installModule(uint256,address,bytes)']),
|
|
67
|
-
functionName: 'installModule',
|
|
68
|
-
args: [module.type, module.address, initData],
|
|
69
|
-
}));
|
|
40
|
+
initConfig.push(...getInstallData(module));
|
|
70
41
|
}
|
|
71
|
-
// Install hooks
|
|
72
42
|
for (const module of moduleSetup.hooks) {
|
|
73
|
-
initConfig.push((
|
|
74
|
-
abi: (0, viem_1.parseAbi)(['function installModule(uint256,address,bytes)']),
|
|
75
|
-
functionName: 'installModule',
|
|
76
|
-
args: [module.type, module.address, module.initData],
|
|
77
|
-
}));
|
|
43
|
+
initConfig.push(...getInstallData(module));
|
|
78
44
|
}
|
|
79
45
|
const initializationCallData = (0, viem_1.encodeFunctionData)({
|
|
80
46
|
abi: (0, viem_1.parseAbi)(['function initialize(bytes21,address,bytes,bytes,bytes[])']),
|
|
@@ -104,6 +70,64 @@ function getAddress(config) {
|
|
|
104
70
|
salt: actualSalt,
|
|
105
71
|
});
|
|
106
72
|
}
|
|
73
|
+
function getInstallData(module) {
|
|
74
|
+
const HOOK_INSTALLED_ADDRESS = '0x0000000000000000000000000000000000000001';
|
|
75
|
+
switch (module.type) {
|
|
76
|
+
case common_1.MODULE_TYPE_ID_VALIDATOR: {
|
|
77
|
+
const data = (0, viem_1.encodeAbiParameters)([{ type: 'bytes' }, { type: 'bytes' }, { type: 'bytes' }], [module.initData, '0x', '0x']);
|
|
78
|
+
const initData = (0, viem_1.concat)([HOOK_INSTALLED_ADDRESS, data]);
|
|
79
|
+
const validatorId = (0, viem_1.concat)(['0x01', module.address]);
|
|
80
|
+
return [
|
|
81
|
+
(0, viem_1.encodeFunctionData)({
|
|
82
|
+
abi: (0, viem_1.parseAbi)(['function installModule(uint256,address,bytes)']),
|
|
83
|
+
functionName: 'installModule',
|
|
84
|
+
args: [module.type, module.address, initData],
|
|
85
|
+
}),
|
|
86
|
+
(0, viem_1.encodeFunctionData)({
|
|
87
|
+
abi: (0, viem_1.parseAbi)(['function grantAccess(bytes21,bytes4,bool)']),
|
|
88
|
+
functionName: 'grantAccess',
|
|
89
|
+
args: [validatorId, '0xe9ae5c53', true],
|
|
90
|
+
}),
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
case common_1.MODULE_TYPE_ID_EXECUTOR: {
|
|
94
|
+
const data = (0, viem_1.encodeAbiParameters)([{ type: 'bytes' }, { type: 'bytes' }], [module.initData, '0x']);
|
|
95
|
+
const initData = (0, viem_1.concat)([viem_1.zeroAddress, data]);
|
|
96
|
+
return [
|
|
97
|
+
(0, viem_1.encodeFunctionData)({
|
|
98
|
+
abi: (0, viem_1.parseAbi)(['function installModule(uint256,address,bytes)']),
|
|
99
|
+
functionName: 'installModule',
|
|
100
|
+
args: [module.type, module.address, initData],
|
|
101
|
+
}),
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
case common_1.MODULE_TYPE_ID_FALLBACK: {
|
|
105
|
+
const [selector, flags, selectorData] = (0, viem_1.decodeAbiParameters)([
|
|
106
|
+
{ name: 'selector', type: 'bytes4' },
|
|
107
|
+
{ name: 'flags', type: 'bytes1' },
|
|
108
|
+
{ name: 'data', type: 'bytes' },
|
|
109
|
+
], module.initData);
|
|
110
|
+
const data = (0, viem_1.encodeAbiParameters)([{ type: 'bytes' }, { type: 'bytes' }], [(0, viem_1.concat)([flags, selectorData]), '0x']);
|
|
111
|
+
const initData = (0, viem_1.concat)([selector, HOOK_INSTALLED_ADDRESS, data]);
|
|
112
|
+
return [
|
|
113
|
+
(0, viem_1.encodeFunctionData)({
|
|
114
|
+
abi: (0, viem_1.parseAbi)(['function installModule(uint256,address,bytes)']),
|
|
115
|
+
functionName: 'installModule',
|
|
116
|
+
args: [module.type, module.address, initData],
|
|
117
|
+
}),
|
|
118
|
+
];
|
|
119
|
+
}
|
|
120
|
+
case common_1.MODULE_TYPE_ID_HOOK: {
|
|
121
|
+
return [
|
|
122
|
+
(0, viem_1.encodeFunctionData)({
|
|
123
|
+
abi: (0, viem_1.parseAbi)(['function installModule(uint256,address,bytes)']),
|
|
124
|
+
functionName: 'installModule',
|
|
125
|
+
args: [module.type, module.address, module.initData],
|
|
126
|
+
}),
|
|
127
|
+
];
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
107
131
|
function get7702InitCalls() {
|
|
108
132
|
throw new Error('EIP-7702 is not yet supported for Kernel accounts');
|
|
109
133
|
}
|
|
@@ -151,6 +175,13 @@ async function getSessionSmartAccount(client, address, session, validatorAddress
|
|
|
151
175
|
return (0, validators_1.encodeSmartSessionSignature)(validators_1.SMART_SESSION_MODE_USE, (0, validators_1.getPermissionId)(session), signature);
|
|
152
176
|
});
|
|
153
177
|
}
|
|
178
|
+
async function getGuardianSmartAccount(client, address, guardians, validatorAddress, sign) {
|
|
179
|
+
return await getBaseSmartAccount(address, client, validatorAddress, 'validator', async () => {
|
|
180
|
+
return (0, validators_1.getMockSignature)(guardians);
|
|
181
|
+
}, async (hash) => {
|
|
182
|
+
return await sign(hash);
|
|
183
|
+
});
|
|
184
|
+
}
|
|
154
185
|
async function getBaseSmartAccount(address, client, validatorAddress, validatorType, getStubSignature, signUserOperation) {
|
|
155
186
|
return await (0, account_abstraction_1.toSmartAccount)({
|
|
156
187
|
client,
|
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const viem_1 = require("viem");
|
|
4
4
|
const vitest_1 = require("vitest");
|
|
5
5
|
const consts_1 = require("../../test/consts");
|
|
6
|
+
const common_1 = require("../modules/common");
|
|
6
7
|
const kernel_1 = require("./kernel");
|
|
8
|
+
const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
7
9
|
(0, vitest_1.describe)('Accounts: Kernel', () => {
|
|
8
10
|
(0, vitest_1.describe)('Deploy Args', () => {
|
|
9
11
|
(0, vitest_1.test)('ECDSA owners', () => {
|
|
@@ -57,6 +59,21 @@ const kernel_1 = require("./kernel");
|
|
|
57
59
|
(0, vitest_1.expect)(address).toEqual('0x2a39d4Ba4F2747041529024acF21aA0D43ABfc43');
|
|
58
60
|
});
|
|
59
61
|
});
|
|
62
|
+
(0, vitest_1.describe)('Get Install Data', () => {
|
|
63
|
+
(0, vitest_1.test)('Module', () => {
|
|
64
|
+
const installData = (0, kernel_1.getInstallData)({
|
|
65
|
+
address: MOCK_MODULE_ADDRESS,
|
|
66
|
+
initData: '0xabcd',
|
|
67
|
+
type: common_1.MODULE_TYPE_ID_VALIDATOR,
|
|
68
|
+
deInitData: '0x0000',
|
|
69
|
+
additionalContext: '0x0000',
|
|
70
|
+
});
|
|
71
|
+
(0, vitest_1.expect)(installData).toEqual([
|
|
72
|
+
'0x9517e29f000000000000000000000000000000000000000000000000000000000000000100000000000000000000000028de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000f40000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000002abcd00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
|
73
|
+
'0xb9b829410128de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f0000000000000000000000e9ae5c53000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001',
|
|
74
|
+
]);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
60
77
|
(0, vitest_1.describe)('Get Packed Signature', () => {
|
|
61
78
|
(0, vitest_1.describe)('Mock signature', () => {
|
|
62
79
|
(0, vitest_1.test)('Root validator', async () => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Abi, Account, Address, Hex, PublicClient } from 'viem';
|
|
2
2
|
import { type SmartAccount, type SmartAccountImplementation } from 'viem/account-abstraction';
|
|
3
|
+
import { Module } from '../modules/common';
|
|
3
4
|
import type { OwnerSet, RhinestoneAccountConfig, Session } from '../types';
|
|
4
5
|
import { ValidatorConfig } from './utils';
|
|
5
6
|
declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
@@ -10,13 +11,15 @@ declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
|
10
11
|
initializationCallData: `0x${string}`;
|
|
11
12
|
};
|
|
12
13
|
declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
|
|
14
|
+
declare function getInstallData(module: Module): `0x${string}`;
|
|
13
15
|
declare function getPackedSignature(signFn: (message: Hex) => Promise<Hex>, hash: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
|
|
14
16
|
declare function getSmartAccount(client: PublicClient, address: Address, owners: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
15
17
|
declare function getSessionSmartAccount(client: PublicClient, address: Address, session: Session, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
18
|
+
declare function getGuardianSmartAccount(client: PublicClient, address: Address, guardians: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
16
19
|
declare function get7702SmartAccount(account: Account, client: PublicClient): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
17
20
|
declare function get7702InitCalls(config: RhinestoneAccountConfig): {
|
|
18
21
|
to: `0x${string}`;
|
|
19
22
|
data: `0x${string}`;
|
|
20
23
|
}[];
|
|
21
|
-
export { getAddress, getPackedSignature, getDeployArgs, getSmartAccount, getSessionSmartAccount, get7702SmartAccount, get7702InitCalls, };
|
|
24
|
+
export { getInstallData, getAddress, getPackedSignature, getDeployArgs, getSmartAccount, getSessionSmartAccount, getGuardianSmartAccount, get7702SmartAccount, get7702InitCalls, };
|
|
22
25
|
//# 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;
|
|
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,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAO1C,OAAO,KAAK,EAAE,QAAQ,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAC1E,OAAO,EAAoC,eAAe,EAAE,MAAM,SAAS,CAAA;AAc3E,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;EA6DrD;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,iBA4BlD;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE,MAAM,iBA2BrC;AAED,iBAAe,kBAAkB,CAC/B,MAAM,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,EACtC,IAAI,EAAE,GAAG,EACT,SAAS,EAAE,eAAe,EAC1B,kBAAkB,GAAE,CAAC,SAAS,EAAE,GAAG,KAAK,GAA8B,0BAQvE;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,iEAWlC;AAED,iBAAe,sBAAsB,CACnC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,OAAO,EACzB,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,iEAuBlC;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,iEAalC;AAED,iBAAe,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,iEAkBxE;AAgFD,iBAAS,gBAAgB,CAAC,MAAM,EAAE,uBAAuB;;;IAqDxD;AAED,OAAO,EACL,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,GACjB,CAAA"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getInstallData = getInstallData;
|
|
3
4
|
exports.getAddress = getAddress;
|
|
4
5
|
exports.getPackedSignature = getPackedSignature;
|
|
5
6
|
exports.getDeployArgs = getDeployArgs;
|
|
6
7
|
exports.getSmartAccount = getSmartAccount;
|
|
7
8
|
exports.getSessionSmartAccount = getSessionSmartAccount;
|
|
9
|
+
exports.getGuardianSmartAccount = getGuardianSmartAccount;
|
|
8
10
|
exports.get7702SmartAccount = get7702SmartAccount;
|
|
9
11
|
exports.get7702InitCalls = get7702InitCalls;
|
|
10
12
|
const viem_1 = require("viem");
|
|
@@ -91,6 +93,34 @@ function getAddress(config) {
|
|
|
91
93
|
const address = (0, viem_1.slice)(hash, 12, 32);
|
|
92
94
|
return address;
|
|
93
95
|
}
|
|
96
|
+
function getInstallData(module) {
|
|
97
|
+
return (0, viem_1.encodeFunctionData)({
|
|
98
|
+
abi: [
|
|
99
|
+
{
|
|
100
|
+
type: 'function',
|
|
101
|
+
name: 'installModule',
|
|
102
|
+
inputs: [
|
|
103
|
+
{
|
|
104
|
+
type: 'uint256',
|
|
105
|
+
name: 'moduleTypeId',
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
type: 'address',
|
|
109
|
+
name: 'module',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
type: 'bytes',
|
|
113
|
+
name: 'initData',
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
outputs: [],
|
|
117
|
+
stateMutability: 'nonpayable',
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
functionName: 'installModule',
|
|
121
|
+
args: [module.type, module.address, module.initData],
|
|
122
|
+
});
|
|
123
|
+
}
|
|
94
124
|
async function getPackedSignature(signFn, hash, validator, transformSignature = (signature) => signature) {
|
|
95
125
|
const signature = await signFn(hash);
|
|
96
126
|
const packedSig = (0, viem_1.encodePacked)(['address', 'bytes'], [validator.address, transformSignature(signature)]);
|
|
@@ -110,6 +140,13 @@ async function getSessionSmartAccount(client, address, session, validatorAddress
|
|
|
110
140
|
return (0, validators_1.encodeSmartSessionSignature)(validators_1.SMART_SESSION_MODE_USE, (0, validators_1.getPermissionId)(session), signature);
|
|
111
141
|
});
|
|
112
142
|
}
|
|
143
|
+
async function getGuardianSmartAccount(client, address, guardians, validatorAddress, sign) {
|
|
144
|
+
return await getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
145
|
+
return (0, validators_1.getMockSignature)(guardians);
|
|
146
|
+
}, async (hash) => {
|
|
147
|
+
return await sign(hash);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
113
150
|
async function get7702SmartAccount(account, client) {
|
|
114
151
|
return await getBaseSmartAccount(account.address, client, viem_1.zeroAddress, async () => {
|
|
115
152
|
const dynamicPart = K1_MEE_VALIDATOR_ADDRESS.substring(2).padEnd(40, '0');
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const vitest_1 = require("vitest");
|
|
4
4
|
const consts_1 = require("../../test/consts");
|
|
5
|
+
const common_1 = require("../modules/common");
|
|
5
6
|
const nexus_1 = require("./nexus");
|
|
7
|
+
const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
6
8
|
(0, vitest_1.describe)('Accounts: Nexus', () => {
|
|
7
9
|
(0, vitest_1.describe)('Deploy Args', () => {
|
|
8
10
|
(0, vitest_1.test)('ECDSA owners', () => {
|
|
@@ -56,6 +58,18 @@ const nexus_1 = require("./nexus");
|
|
|
56
58
|
(0, vitest_1.expect)(address).toEqual('0x75851281e7af9b9ebaf42abacce566d2a26c0cd7');
|
|
57
59
|
});
|
|
58
60
|
});
|
|
61
|
+
(0, vitest_1.describe)('Get Install Data', () => {
|
|
62
|
+
(0, vitest_1.test)('Module', () => {
|
|
63
|
+
const installData = (0, nexus_1.getInstallData)({
|
|
64
|
+
address: MOCK_MODULE_ADDRESS,
|
|
65
|
+
initData: '0xabcd',
|
|
66
|
+
type: common_1.MODULE_TYPE_ID_VALIDATOR,
|
|
67
|
+
deInitData: '0x0000',
|
|
68
|
+
additionalContext: '0x0000',
|
|
69
|
+
});
|
|
70
|
+
(0, vitest_1.expect)(installData).toEqual('0x9517e29f000000000000000000000000000000000000000000000000000000000000000100000000000000000000000028de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000002abcd000000000000000000000000000000000000000000000000000000000000');
|
|
71
|
+
});
|
|
72
|
+
});
|
|
59
73
|
(0, vitest_1.describe)('Get Packed Signature', () => {
|
|
60
74
|
(0, vitest_1.test)('Mock signature', async () => {
|
|
61
75
|
const hash = '0xabcd';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Abi, type Address, type Hex, type PublicClient } from 'viem';
|
|
2
2
|
import { type SmartAccount, type SmartAccountImplementation } from 'viem/account-abstraction';
|
|
3
|
+
import { Module } from '../modules/common';
|
|
3
4
|
import type { OwnerSet, RhinestoneAccountConfig, Session } from '../types';
|
|
4
5
|
import { ValidatorConfig } from './utils';
|
|
5
6
|
declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
@@ -10,10 +11,12 @@ declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
|
10
11
|
initializationCallData: null;
|
|
11
12
|
};
|
|
12
13
|
declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
|
|
14
|
+
declare function getInstallData(module: Module): `0x${string}`;
|
|
13
15
|
declare function getPackedSignature(signFn: (message: Hex) => Promise<Hex>, hash: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
|
|
14
16
|
declare function getSmartAccount(client: PublicClient, address: Address, owners: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
15
17
|
declare function getSessionSmartAccount(client: PublicClient, address: Address, session: Session, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
18
|
+
declare function getGuardianSmartAccount(client: PublicClient, address: Address, guardians: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
16
19
|
declare function get7702SmartAccount(): never;
|
|
17
20
|
declare function get7702InitCalls(): never;
|
|
18
|
-
export { getAddress, getPackedSignature, getDeployArgs, getSmartAccount, getSessionSmartAccount, get7702InitCalls, get7702SmartAccount, };
|
|
21
|
+
export { getInstallData, getAddress, getPackedSignature, getDeployArgs, getSmartAccount, getSessionSmartAccount, getGuardianSmartAccount, get7702InitCalls, get7702SmartAccount, };
|
|
19
22
|
//# sourceMappingURL=safe.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../../../accounts/safe.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,
|
|
1
|
+
{"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../../../accounts/safe.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EAER,KAAK,OAAO,EAIZ,KAAK,GAAG,EAER,KAAK,YAAY,EAIlB,MAAM,MAAM,CAAA;AACb,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAEhC,MAAM,0BAA0B,CAAA;AAGjC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAO1C,OAAO,KAAK,EAAE,QAAQ,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAC1E,OAAO,EAAoC,eAAe,EAAE,MAAM,SAAS,CAAA;AAc3E,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;EAsErD;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,iBAalD;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE,MAAM,iBA2BrC;AAED,iBAAe,kBAAkB,CAC/B,MAAM,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,EACtC,IAAI,EAAE,GAAG,EACT,SAAS,EAAE,eAAe,EAC1B,kBAAkB,GAAE,CAAC,SAAS,EAAE,GAAG,KAAK,GAA8B,0BAQvE;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,iEAWlC;AAED,iBAAe,sBAAsB,CACnC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,OAAO,EACzB,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,iEAuBlC;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,iEAalC;AA0ED,iBAAS,mBAAmB,IAAI,KAAK,CAEpC;AAED,iBAAS,gBAAgB,IAAI,KAAK,CAEjC;AAsBD,OAAO,EACL,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,gBAAgB,EAChB,mBAAmB,GACpB,CAAA"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getInstallData = getInstallData;
|
|
3
4
|
exports.getAddress = getAddress;
|
|
4
5
|
exports.getPackedSignature = getPackedSignature;
|
|
5
6
|
exports.getDeployArgs = getDeployArgs;
|
|
6
7
|
exports.getSmartAccount = getSmartAccount;
|
|
7
8
|
exports.getSessionSmartAccount = getSessionSmartAccount;
|
|
9
|
+
exports.getGuardianSmartAccount = getGuardianSmartAccount;
|
|
8
10
|
exports.get7702InitCalls = get7702InitCalls;
|
|
9
11
|
exports.get7702SmartAccount = get7702SmartAccount;
|
|
10
12
|
const viem_1 = require("viem");
|
|
@@ -90,6 +92,34 @@ function getAddress(config) {
|
|
|
90
92
|
const address = (0, viem_1.slice)(hash, 12, 32);
|
|
91
93
|
return address;
|
|
92
94
|
}
|
|
95
|
+
function getInstallData(module) {
|
|
96
|
+
return (0, viem_1.encodeFunctionData)({
|
|
97
|
+
abi: [
|
|
98
|
+
{
|
|
99
|
+
type: 'function',
|
|
100
|
+
name: 'installModule',
|
|
101
|
+
inputs: [
|
|
102
|
+
{
|
|
103
|
+
type: 'uint256',
|
|
104
|
+
name: 'moduleTypeId',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
type: 'address',
|
|
108
|
+
name: 'module',
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
type: 'bytes',
|
|
112
|
+
name: 'initData',
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
outputs: [],
|
|
116
|
+
stateMutability: 'nonpayable',
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
functionName: 'installModule',
|
|
120
|
+
args: [module.type, module.address, module.initData],
|
|
121
|
+
});
|
|
122
|
+
}
|
|
93
123
|
async function getPackedSignature(signFn, hash, validator, transformSignature = (signature) => signature) {
|
|
94
124
|
const signature = await signFn(hash);
|
|
95
125
|
const packedSig = (0, viem_1.encodePacked)(['address', 'bytes'], [validator.address, transformSignature(signature)]);
|
|
@@ -109,6 +139,13 @@ async function getSessionSmartAccount(client, address, session, validatorAddress
|
|
|
109
139
|
return (0, validators_1.encodeSmartSessionSignature)(validators_1.SMART_SESSION_MODE_USE, (0, validators_1.getPermissionId)(session), signature);
|
|
110
140
|
});
|
|
111
141
|
}
|
|
142
|
+
async function getGuardianSmartAccount(client, address, guardians, validatorAddress, sign) {
|
|
143
|
+
return await getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
144
|
+
return (0, validators_1.getMockSignature)(guardians);
|
|
145
|
+
}, async (hash) => {
|
|
146
|
+
return await sign(hash);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
112
149
|
async function getBaseSmartAccount(address, client, validatorAddress, getStubSignature, signUserOperation) {
|
|
113
150
|
return await (0, account_abstraction_1.toSmartAccount)({
|
|
114
151
|
client,
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const vitest_1 = require("vitest");
|
|
4
4
|
const consts_1 = require("../../test/consts");
|
|
5
|
+
const common_1 = require("../modules/common");
|
|
5
6
|
const safe_1 = require("./safe");
|
|
7
|
+
const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
6
8
|
(0, vitest_1.describe)('Accounts: Safe', () => {
|
|
7
9
|
(0, vitest_1.describe)('Deploy Args', () => {
|
|
8
10
|
(0, vitest_1.test)('ECDSA owners', () => {
|
|
@@ -56,6 +58,18 @@ const safe_1 = require("./safe");
|
|
|
56
58
|
(0, vitest_1.expect)(address).toEqual('0x033e622d8626b225cad07bcab182d1a09f514f70');
|
|
57
59
|
});
|
|
58
60
|
});
|
|
61
|
+
(0, vitest_1.describe)('Get Install Data', () => {
|
|
62
|
+
(0, vitest_1.test)('Module', () => {
|
|
63
|
+
const installData = (0, safe_1.getInstallData)({
|
|
64
|
+
address: MOCK_MODULE_ADDRESS,
|
|
65
|
+
initData: '0xabcd',
|
|
66
|
+
type: common_1.MODULE_TYPE_ID_VALIDATOR,
|
|
67
|
+
deInitData: '0x0000',
|
|
68
|
+
additionalContext: '0x0000',
|
|
69
|
+
});
|
|
70
|
+
(0, vitest_1.expect)(installData).toEqual('0x9517e29f000000000000000000000000000000000000000000000000000000000000000100000000000000000000000028de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000002abcd000000000000000000000000000000000000000000000000000000000000');
|
|
71
|
+
});
|
|
72
|
+
});
|
|
59
73
|
(0, vitest_1.describe)('Get Packed Signature', () => {
|
|
60
74
|
(0, vitest_1.test)('Mock signature', async () => {
|
|
61
75
|
const hash = '0xabcd';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Address, Chain } from 'viem';
|
|
2
|
+
import { RhinestoneAccount } from '..';
|
|
3
|
+
import { Call, OwnerSet, Recovery } from '../types';
|
|
4
|
+
declare function setUpRecovery({ rhinestoneAccount, guardians, threshold, }: {
|
|
5
|
+
rhinestoneAccount: RhinestoneAccount;
|
|
6
|
+
} & Recovery): Call[];
|
|
7
|
+
declare function recover(address: Address, newOwners: OwnerSet, chain: Chain): Promise<Call[]>;
|
|
8
|
+
declare function addOwner(owner: Address): Call;
|
|
9
|
+
declare function removeOwner(prevOwner: Address, ownerToRemove: Address): Call;
|
|
10
|
+
declare function setThreshold(newThreshold: bigint): Call;
|
|
11
|
+
export { addOwner, removeOwner, setThreshold, recover, setUpRecovery };
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,KAAK,EAIN,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAA;AAMtC,OAAO,EAAE,IAAI,EAA0B,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAE3E,iBAAS,aAAa,CAAC,EACrB,iBAAiB,EACjB,SAAS,EACT,SAAa,GACd,EAAE;IACD,iBAAiB,EAAE,iBAAiB,CAAA;CACrC,GAAG,QAAQ,UAIX;AAED,iBAAe,OAAO,CACpB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,QAAQ,EACnB,KAAK,EAAE,KAAK,GACX,OAAO,CAAC,IAAI,EAAE,CAAC,CASjB;AAED,iBAAS,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAiBtC;AAED,iBAAS,WAAW,CAAC,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,GAAG,IAAI,CAoBrE;AAED,iBAAS,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAmBhD;AAqGD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,CAAA"}
|