@rhinestone/sdk 1.0.0-alpha.1 → 1.0.0-alpha.11
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/error.d.ts.map +1 -1
- package/dist/src/accounts/error.js +2 -0
- package/dist/src/accounts/index.d.ts +15 -8
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +204 -164
- package/dist/src/accounts/index.test.js +2 -2
- package/dist/src/accounts/kernel.d.ts +7 -9
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +0 -9
- package/dist/src/accounts/kernel.test.js +6 -6
- package/dist/src/accounts/nexus.d.ts +14 -13
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +91 -88
- package/dist/src/accounts/nexus.test.js +10 -10
- package/dist/src/accounts/safe.d.ts +4 -6
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +20 -30
- package/dist/src/accounts/safe.test.js +6 -6
- package/dist/src/accounts/startale.d.ts +20 -0
- package/dist/src/accounts/startale.d.ts.map +1 -0
- package/dist/src/accounts/startale.js +100 -0
- package/dist/src/accounts/startale.test.d.ts +2 -0
- package/dist/src/accounts/startale.test.d.ts.map +1 -0
- package/dist/src/accounts/startale.test.js +97 -0
- package/dist/src/accounts/utils.d.ts +4 -3
- package/dist/src/accounts/utils.d.ts.map +1 -1
- package/dist/src/accounts/utils.js +44 -0
- package/dist/src/actions/index.d.ts +17 -7
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +108 -15
- package/dist/src/actions/index.test.js +35 -17
- package/dist/src/actions/smart-session.d.ts +2 -2
- package/dist/src/actions/smart-session.d.ts.map +1 -1
- package/dist/src/execution/compact.d.ts +6 -3
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +44 -1
- package/dist/src/execution/error.d.ts +2 -9
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +4 -13
- package/dist/src/execution/index.d.ts +2 -3
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +34 -49
- package/dist/src/execution/smart-session.d.ts +1 -1
- package/dist/src/execution/smart-session.d.ts.map +1 -1
- package/dist/src/execution/smart-session.js +12 -17
- package/dist/src/execution/utils.d.ts +13 -11
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +150 -84
- package/dist/src/index.d.ts +14 -14
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +24 -20
- package/dist/src/modules/index.d.ts +3 -7
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +1 -10
- package/dist/src/modules/index.test.js +2 -2
- package/dist/src/modules/omni-account.d.ts +1 -4
- package/dist/src/modules/omni-account.d.ts.map +1 -1
- package/dist/src/modules/omni-account.js +2 -8
- package/dist/src/modules/read.d.ts +5 -6
- package/dist/src/modules/read.d.ts.map +1 -1
- package/dist/src/modules/read.js +6 -37
- package/dist/src/modules/validators/core.d.ts +6 -7
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +83 -8
- package/dist/src/modules/validators/core.test.js +4 -4
- package/dist/src/modules/validators/smart-sessions.d.ts +3 -3
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
- package/dist/src/modules/validators/smart-sessions.js +7 -6
- package/dist/src/modules/validators/smart-sessions.test.js +4 -4
- package/dist/src/orchestrator/client.d.ts +1 -0
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +136 -94
- package/dist/src/orchestrator/consts.d.ts +3 -3
- package/dist/src/orchestrator/consts.d.ts.map +1 -1
- package/dist/src/orchestrator/consts.js +4 -4
- package/dist/src/orchestrator/index.d.ts +2 -2
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +1 -7
- package/dist/src/orchestrator/registry.d.ts +31 -12
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +57 -380
- package/dist/src/orchestrator/registry.json +365 -0
- package/dist/src/orchestrator/registry.test.d.ts.map +1 -0
- package/dist/src/orchestrator/registry.test.js +137 -0
- package/dist/src/orchestrator/types.d.ts +81 -14
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/orchestrator/utils.d.ts.map +1 -1
- package/dist/src/orchestrator/utils.js +2 -2
- package/dist/src/types.d.ts +42 -21
- package/dist/src/types.d.ts.map +1 -1
- package/dist/test/consts.d.ts +2 -2
- package/dist/test/consts.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/src/actions/registry.d.ts +0 -7
- package/dist/src/actions/registry.d.ts.map +0 -1
- package/dist/src/actions/registry.js +0 -7
- package/dist/src/actions/registry.test.d.ts.map +0 -1
- package/dist/src/actions/registry.test.js +0 -25
- package/dist/src/modules/registry.d.ts +0 -13
- package/dist/src/modules/registry.d.ts.map +0 -1
- package/dist/src/modules/registry.js +0 -67
- /package/dist/src/{actions → orchestrator}/registry.test.d.ts +0 -0
|
@@ -17,10 +17,10 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
17
17
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
18
18
|
});
|
|
19
19
|
(0, vitest_1.expect)(factory).toEqual('0xd703aae79538628d27099b8c4f621be4ccd142d5');
|
|
20
|
-
(0, vitest_1.expect)(factoryData).toEqual('
|
|
20
|
+
(0, vitest_1.expect)(factoryData).toEqual('0xc5265d5d0000000000000000000000002577507b78c2008ff367261cb6285d44ba5ef2e90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003243c3b752b010000000000E9E6E96Bcaa3c113187CdB7E38AED90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000094000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
21
21
|
(0, vitest_1.expect)(salt).toEqual('0x0000000000000000000000000000000000000000000000000000000000000000');
|
|
22
22
|
(0, vitest_1.expect)(implementation).toEqual('0xd6CEDDe84be40893d153Be9d467CD6aD37875b28');
|
|
23
|
-
(0, vitest_1.expect)(initializationCallData).toEqual('
|
|
23
|
+
(0, vitest_1.expect)(initializationCallData).toEqual('0x3c3b752b010000000000E9E6E96Bcaa3c113187CdB7E38AED90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
24
24
|
});
|
|
25
25
|
(0, vitest_1.test)('Passkey owner', () => {
|
|
26
26
|
const { factory, factoryData, salt, implementation, initializationCallData, } = (0, kernel_1.getDeployArgs)({
|
|
@@ -31,10 +31,10 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
31
31
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
32
32
|
});
|
|
33
33
|
(0, vitest_1.expect)(factory).toEqual('0xd703aae79538628d27099b8c4f621be4ccd142d5');
|
|
34
|
-
(0, vitest_1.expect)(factoryData).toEqual('
|
|
34
|
+
(0, vitest_1.expect)(factoryData).toEqual('0xc5265d5d0000000000000000000000002577507b78c2008ff367261cb6285d44ba5ef2e90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e43c3b752b010000000000578c4cB0e472a5462da43C495C3F330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000060580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d19c9a01073b202db2ed56e604ad11db557d8c3ad75181619597f21b830f2da82a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000094000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
35
35
|
(0, vitest_1.expect)(salt).toEqual('0x0000000000000000000000000000000000000000000000000000000000000000');
|
|
36
36
|
(0, vitest_1.expect)(implementation).toEqual('0xd6CEDDe84be40893d153Be9d467CD6aD37875b28');
|
|
37
|
-
(0, vitest_1.expect)(initializationCallData).toEqual('
|
|
37
|
+
(0, vitest_1.expect)(initializationCallData).toEqual('0x3c3b752b010000000000578c4cB0e472a5462da43C495C3F330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000060580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d19c9a01073b202db2ed56e604ad11db557d8c3ad75181619597f21b830f2da82a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
38
38
|
});
|
|
39
39
|
});
|
|
40
40
|
(0, vitest_1.describe)('Get Address', () => {
|
|
@@ -46,7 +46,7 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
46
46
|
},
|
|
47
47
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
48
48
|
});
|
|
49
|
-
(0, vitest_1.expect)(address).toEqual('
|
|
49
|
+
(0, vitest_1.expect)(address).toEqual('0xe4090134D2FdC0fc13b43651B5b1c75BDf825c5f');
|
|
50
50
|
});
|
|
51
51
|
(0, vitest_1.test)('Passkey owner', () => {
|
|
52
52
|
const address = (0, kernel_1.getAddress)({
|
|
@@ -56,7 +56,7 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
56
56
|
},
|
|
57
57
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
58
58
|
});
|
|
59
|
-
(0, vitest_1.expect)(address).toEqual('
|
|
59
|
+
(0, vitest_1.expect)(address).toEqual('0x5a4063A8f32201C84B8e7a073C7494D53D7dFAe7');
|
|
60
60
|
});
|
|
61
61
|
});
|
|
62
62
|
(0, vitest_1.describe)('Get Install Data', () => {
|
|
@@ -1,26 +1,27 @@
|
|
|
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';
|
|
4
|
-
import { EnableSessionData } from '../modules/validators/smart-sessions';
|
|
3
|
+
import type { Module } from '../modules/common';
|
|
4
|
+
import type { EnableSessionData } from '../modules/validators/smart-sessions';
|
|
5
5
|
import type { OwnerSet, RhinestoneAccountConfig, Session } from '../types';
|
|
6
|
-
import { ValidatorConfig } from './utils';
|
|
6
|
+
import { type ValidatorConfig } from './utils';
|
|
7
7
|
declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
8
8
|
factory: `0x${string}`;
|
|
9
9
|
factoryData: `0x${string}`;
|
|
10
10
|
salt: `0x${string}`;
|
|
11
11
|
implementation: `0x${string}`;
|
|
12
12
|
initializationCallData: `0x${string}`;
|
|
13
|
+
initData: `0x${string}`;
|
|
13
14
|
};
|
|
14
15
|
declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
|
|
15
16
|
declare function getInstallData(module: Module): `0x${string}`;
|
|
16
|
-
declare function getPackedSignature(signFn: (message: Hex) => Promise<Hex>, hash: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
|
|
17
|
-
declare function getSmartAccount(client: PublicClient, address: Address, owners: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex
|
|
18
|
-
declare function getSessionSmartAccount(client: PublicClient, address: Address, session: Session, validatorAddress: Address, enableData: EnableSessionData | null, sign: (hash: Hex) => Promise<Hex
|
|
19
|
-
declare function getGuardianSmartAccount(client: PublicClient, address: Address, guardians: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex
|
|
20
|
-
declare function
|
|
21
|
-
declare function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
export { getInstallData, getAddress, getPackedSignature, getDeployArgs, getSmartAccount, getSessionSmartAccount, getGuardianSmartAccount,
|
|
17
|
+
declare function getPackedSignature(signFn: (message: Hex) => Promise<Hex>, hash: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex, defaultValidatorAddress?: Address): Promise<`0x${string}`>;
|
|
18
|
+
declare function getSmartAccount(client: PublicClient, address: Address, owners: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>, defaultValidatorAddress?: Address): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
19
|
+
declare function getSessionSmartAccount(client: PublicClient, address: Address, session: Session, validatorAddress: Address, enableData: EnableSessionData | null, sign: (hash: Hex) => Promise<Hex>, defaultValidatorAddress?: Address): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
20
|
+
declare function getGuardianSmartAccount(client: PublicClient, address: Address, guardians: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>, defaultValidatorAddress?: Address): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
21
|
+
declare function signEip7702InitData(config: RhinestoneAccountConfig, eoa: Account): Promise<`0x${string}`>;
|
|
22
|
+
declare function getEip7702InitCall(config: RhinestoneAccountConfig, signature: Hex): Promise<{
|
|
23
|
+
initData: `0x${string}`;
|
|
24
|
+
contract: `0x${string}`;
|
|
25
|
+
}>;
|
|
26
|
+
export { getInstallData, getAddress, getPackedSignature, getDeployArgs, getSmartAccount, getSessionSmartAccount, getGuardianSmartAccount, signEip7702InitData, getEip7702InitCall, };
|
|
26
27
|
//# sourceMappingURL=nexus.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nexus.d.ts","sourceRoot":"","sources":["../../../accounts/nexus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAYpE,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAEhC,MAAM,0BAA0B,CAAA;AAGjC,OAAO,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;AAYpE,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAEhC,MAAM,0BAA0B,CAAA;AAGjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAS/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAC7E,OAAO,KAAK,EAAE,QAAQ,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAE1E,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAchF,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;;EAmErD;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,EACtE,uBAAuB,GAAE,OAAyC,0BAYnE;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,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,GACnB,CAAA"}
|
|
@@ -7,34 +7,41 @@ exports.getDeployArgs = getDeployArgs;
|
|
|
7
7
|
exports.getSmartAccount = getSmartAccount;
|
|
8
8
|
exports.getSessionSmartAccount = getSessionSmartAccount;
|
|
9
9
|
exports.getGuardianSmartAccount = getGuardianSmartAccount;
|
|
10
|
-
exports.
|
|
11
|
-
exports.
|
|
10
|
+
exports.signEip7702InitData = signEip7702InitData;
|
|
11
|
+
exports.getEip7702InitCall = getEip7702InitCall;
|
|
12
12
|
const viem_1 = require("viem");
|
|
13
13
|
const account_abstraction_1 = require("viem/account-abstraction");
|
|
14
14
|
const modules_1 = require("../modules");
|
|
15
15
|
const validators_1 = require("../modules/validators");
|
|
16
|
+
const core_1 = require("../modules/validators/core");
|
|
16
17
|
const error_1 = require("./error");
|
|
17
18
|
const utils_1 = require("./utils");
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
19
|
+
const NEXUS_DEFAULT_VALIDATOR_ADDRESS = core_1.OWNABLE_VALIDATOR_ADDRESS;
|
|
20
|
+
const NEXUS_IMPLEMENTATION_ADDRESS = '0x0000000000Fb742636364B5ca9B6D2ebbC63FB5D';
|
|
21
|
+
const NEXUS_FACTORY_ADDRESS = '0x0000000000751F0a4816c34fB95ccbD463878361';
|
|
22
|
+
const NEXUS_BOOTSTRAP_ADDRESS = '0x00000000001Cf4667Bfd7be8f67D01d63938784b';
|
|
22
23
|
const NEXUS_CREATION_CODE = '0x60806040526102aa803803806100148161018c565b92833981016040828203126101885781516001600160a01b03811692909190838303610188576020810151906001600160401b03821161018857019281601f8501121561018857835161006e610069826101c5565b61018c565b9481865260208601936020838301011161018857815f926020809301865e8601015260017f90b772c2cb8a51aa7a8a65fc23543c6d022d5b3f8e2b92eed79fba7eef8293005d823b15610176577f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b031916821790557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b5f80a282511561015e575f8091610146945190845af43d15610156573d91610137610069846101c5565b9283523d5f602085013e6101e0565b505b604051606b908161023f8239f35b6060916101e0565b50505034156101485763b398979f60e01b5f5260045ffd5b634c9c8ce360e01b5f5260045260245ffd5b5f80fd5b6040519190601f01601f191682016001600160401b038111838210176101b157604052565b634e487b7160e01b5f52604160045260245ffd5b6001600160401b0381116101b157601f01601f191660200190565b9061020457508051156101f557805190602001fd5b63d6bda27560e01b5f5260045ffd5b81511580610235575b610215575090565b639996b31560e01b5f9081526001600160a01b0391909116600452602490fd5b50803b1561020d56fe60806040523615605c575f8073ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416368280378136915af43d5f803e156058573d5ff35b3d5ffd5b00fea164736f6c634300081b000a';
|
|
23
24
|
function getDeployArgs(config) {
|
|
24
25
|
const salt = (0, viem_1.keccak256)('0x');
|
|
25
26
|
const moduleSetup = (0, modules_1.getSetup)(config);
|
|
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);
|
|
26
33
|
const initData = (0, viem_1.encodeAbiParameters)([{ type: 'address' }, { type: 'bytes' }], [
|
|
27
34
|
NEXUS_BOOTSTRAP_ADDRESS,
|
|
28
35
|
(0, viem_1.encodeFunctionData)({
|
|
29
36
|
abi: (0, viem_1.parseAbi)([
|
|
30
37
|
'struct BootstrapConfig {address module;bytes initData;}',
|
|
31
38
|
'struct BootstrapPreValidationHookConfig {uint256 hookType;address module;bytes data;}',
|
|
32
|
-
'
|
|
33
|
-
'function initNexus(BootstrapConfig[] calldata validators,BootstrapConfig[] calldata executors,BootstrapConfig calldata hook,BootstrapConfig[] calldata fallbacks,BootstrapPreValidationHookConfig[] calldata preValidationHooks,RegistryConfig registryConfig) external',
|
|
39
|
+
'function initNexusWithDefaultValidatorAndOtherModulesNoRegistry(bytes calldata defaultValidatorInitData,BootstrapConfig[] calldata validators,BootstrapConfig[] calldata executors,BootstrapConfig calldata hook,BootstrapConfig[] calldata fallbacks,BootstrapPreValidationHookConfig[] calldata preValidationHooks) external',
|
|
34
40
|
]),
|
|
35
|
-
functionName: '
|
|
41
|
+
functionName: 'initNexusWithDefaultValidatorAndOtherModulesNoRegistry',
|
|
36
42
|
args: [
|
|
37
|
-
|
|
43
|
+
defaultValidatorInitData,
|
|
44
|
+
validators.map((v) => ({
|
|
38
45
|
module: v.address,
|
|
39
46
|
initData: v.initData,
|
|
40
47
|
})),
|
|
@@ -51,11 +58,6 @@ function getDeployArgs(config) {
|
|
|
51
58
|
initData: f.initData,
|
|
52
59
|
})),
|
|
53
60
|
[],
|
|
54
|
-
{
|
|
55
|
-
registry: moduleSetup.registry,
|
|
56
|
-
attesters: moduleSetup.attesters,
|
|
57
|
-
threshold: moduleSetup.threshold,
|
|
58
|
-
},
|
|
59
61
|
],
|
|
60
62
|
}),
|
|
61
63
|
]);
|
|
@@ -75,6 +77,7 @@ function getDeployArgs(config) {
|
|
|
75
77
|
salt,
|
|
76
78
|
implementation: NEXUS_IMPLEMENTATION_ADDRESS,
|
|
77
79
|
initializationCallData,
|
|
80
|
+
initData,
|
|
78
81
|
};
|
|
79
82
|
}
|
|
80
83
|
function getAddress(config) {
|
|
@@ -122,17 +125,20 @@ function getInstallData(module) {
|
|
|
122
125
|
args: [module.type, module.address, module.initData],
|
|
123
126
|
});
|
|
124
127
|
}
|
|
125
|
-
async function getPackedSignature(signFn, hash, validator, transformSignature = (signature) => signature) {
|
|
128
|
+
async function getPackedSignature(signFn, hash, validator, transformSignature = (signature) => signature, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
|
|
126
129
|
const signature = await signFn(hash);
|
|
127
|
-
const
|
|
130
|
+
const validatorAddress = validator.address === defaultValidatorAddress
|
|
131
|
+
? viem_1.zeroAddress
|
|
132
|
+
: validator.address;
|
|
133
|
+
const packedSig = (0, viem_1.encodePacked)(['address', 'bytes'], [validatorAddress, transformSignature(signature)]);
|
|
128
134
|
return packedSig;
|
|
129
135
|
}
|
|
130
|
-
async function getSmartAccount(client, address, owners, validatorAddress, sign) {
|
|
136
|
+
async function getSmartAccount(client, address, owners, validatorAddress, sign, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
|
|
131
137
|
return getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
132
138
|
return (0, validators_1.getMockSignature)(owners);
|
|
133
|
-
}, sign);
|
|
139
|
+
}, sign, defaultValidatorAddress);
|
|
134
140
|
}
|
|
135
|
-
async function getSessionSmartAccount(client, address, session, validatorAddress, enableData, sign) {
|
|
141
|
+
async function getSessionSmartAccount(client, address, session, validatorAddress, enableData, sign, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
|
|
136
142
|
return await getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
137
143
|
const dummyOpSignature = (0, validators_1.getMockSignature)(session.owners);
|
|
138
144
|
if (enableData) {
|
|
@@ -145,29 +151,16 @@ async function getSessionSmartAccount(client, address, session, validatorAddress
|
|
|
145
151
|
return (0, validators_1.encodeSmartSessionSignature)(validators_1.SMART_SESSION_MODE_ENABLE, (0, validators_1.getPermissionId)(session), signature, enableData);
|
|
146
152
|
}
|
|
147
153
|
return (0, validators_1.encodeSmartSessionSignature)(validators_1.SMART_SESSION_MODE_USE, (0, validators_1.getPermissionId)(session), signature);
|
|
148
|
-
});
|
|
154
|
+
}, defaultValidatorAddress);
|
|
149
155
|
}
|
|
150
|
-
async function getGuardianSmartAccount(client, address, guardians, validatorAddress, sign) {
|
|
156
|
+
async function getGuardianSmartAccount(client, address, guardians, validatorAddress, sign, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
|
|
151
157
|
return await getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
152
158
|
return (0, validators_1.getMockSignature)(guardians);
|
|
153
159
|
}, async (hash) => {
|
|
154
160
|
return await sign(hash);
|
|
155
|
-
});
|
|
161
|
+
}, defaultValidatorAddress);
|
|
156
162
|
}
|
|
157
|
-
async function
|
|
158
|
-
return await getBaseSmartAccount(account.address, client, viem_1.zeroAddress, async () => {
|
|
159
|
-
const dynamicPart = K1_MEE_VALIDATOR_ADDRESS.substring(2).padEnd(40, '0');
|
|
160
|
-
return `0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000${dynamicPart}000000000000000000000000000000000000000000000000000000000000004181d4b4981670cb18f99f0b4a66446df1bf5b204d24cfcb659bf38ba27a4359b5711649ec2423c5e1247245eba2964679b6a1dbb85c992ae40b9b00c6935b02ff1b00000000000000000000000000000000000000000000000000000000000000`;
|
|
161
|
-
}, async (hash) => {
|
|
162
|
-
if (!account.signMessage) {
|
|
163
|
-
throw new error_1.SignMessageNotSupportedByAccountError();
|
|
164
|
-
}
|
|
165
|
-
return await account.signMessage({
|
|
166
|
-
message: { raw: hash },
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
async function getBaseSmartAccount(address, client, nonceValidatorAddress, getStubSignature, signUserOperation) {
|
|
163
|
+
async function getBaseSmartAccount(address, client, nonceValidatorAddress, getStubSignature, signUserOperation, defaultValidatorAddress) {
|
|
171
164
|
return await (0, account_abstraction_1.toSmartAccount)({
|
|
172
165
|
client,
|
|
173
166
|
entryPoint: {
|
|
@@ -196,13 +189,16 @@ async function getBaseSmartAccount(address, client, nonceValidatorAddress, getSt
|
|
|
196
189
|
return {};
|
|
197
190
|
},
|
|
198
191
|
async getNonce(args) {
|
|
192
|
+
const validatorAddress = nonceValidatorAddress === defaultValidatorAddress
|
|
193
|
+
? viem_1.zeroAddress
|
|
194
|
+
: nonceValidatorAddress;
|
|
199
195
|
const TIMESTAMP_ADJUSTMENT = 16777215n; // max value for size 3
|
|
200
196
|
const defaultedKey = (args?.key ?? 0n) % TIMESTAMP_ADJUSTMENT;
|
|
201
197
|
const defaultedValidationMode = '0x00';
|
|
202
198
|
const key = (0, viem_1.concat)([
|
|
203
199
|
(0, viem_1.toHex)(defaultedKey, { size: 3 }),
|
|
204
200
|
defaultedValidationMode,
|
|
205
|
-
|
|
201
|
+
validatorAddress,
|
|
206
202
|
]);
|
|
207
203
|
return (0, utils_1.getAccountNonce)(client, {
|
|
208
204
|
address,
|
|
@@ -237,56 +233,63 @@ async function getBaseSmartAccount(address, client, nonceValidatorAddress, getSt
|
|
|
237
233
|
},
|
|
238
234
|
});
|
|
239
235
|
}
|
|
240
|
-
function
|
|
241
|
-
const
|
|
242
|
-
if (!eoa) {
|
|
243
|
-
throw new error_1.
|
|
236
|
+
async function signEip7702InitData(config, eoa) {
|
|
237
|
+
const { initData } = getDeployArgs(config);
|
|
238
|
+
if (!eoa.signTypedData) {
|
|
239
|
+
throw new error_1.SigningNotSupportedForAccountError();
|
|
244
240
|
}
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
moduleSetup.attesters,
|
|
257
|
-
moduleSetup.threshold,
|
|
258
|
-
],
|
|
259
|
-
}),
|
|
241
|
+
const signature = await eoa.signTypedData({
|
|
242
|
+
domain: {
|
|
243
|
+
name: 'Nexus',
|
|
244
|
+
version: '1.2.0',
|
|
245
|
+
},
|
|
246
|
+
types: {
|
|
247
|
+
Initialize: [
|
|
248
|
+
{ name: 'nexus', type: 'address' },
|
|
249
|
+
{ name: 'chainIds', type: 'uint256[]' },
|
|
250
|
+
{ name: 'initData', type: 'bytes' },
|
|
251
|
+
],
|
|
260
252
|
},
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
253
|
+
primaryType: 'Initialize',
|
|
254
|
+
message: {
|
|
255
|
+
nexus: NEXUS_IMPLEMENTATION_ADDRESS,
|
|
256
|
+
chainIds: [0n],
|
|
257
|
+
initData,
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
return signature;
|
|
261
|
+
}
|
|
262
|
+
async function getEip7702InitCall(config, signature) {
|
|
263
|
+
function getEncodedData(initData) {
|
|
264
|
+
const chainIds = [0n];
|
|
265
|
+
const chainIdIndex = 0n;
|
|
266
|
+
const chainIdsLength = 1n;
|
|
267
|
+
const encodedData = (0, viem_1.encodePacked)(['uint256', 'uint256', 'uint256', 'bytes'], [chainIdIndex, chainIdsLength, chainIds[0], initData]);
|
|
268
|
+
return encodedData;
|
|
269
|
+
}
|
|
270
|
+
const { initData } = getDeployArgs(config);
|
|
271
|
+
const encodedData = getEncodedData(initData);
|
|
272
|
+
const accountFullData = (0, viem_1.concat)([signature, encodedData]);
|
|
273
|
+
const accountInitCallData = (0, viem_1.encodeFunctionData)({
|
|
274
|
+
abi: [
|
|
275
|
+
{
|
|
276
|
+
type: 'function',
|
|
277
|
+
inputs: [
|
|
278
|
+
{
|
|
279
|
+
type: 'bytes',
|
|
280
|
+
name: 'initData',
|
|
281
|
+
},
|
|
282
|
+
],
|
|
283
|
+
outputs: [],
|
|
284
|
+
stateMutability: 'nonpayable',
|
|
285
|
+
name: 'initializeAccount',
|
|
286
|
+
},
|
|
287
|
+
],
|
|
288
|
+
functionName: 'initializeAccount',
|
|
289
|
+
args: [accountFullData],
|
|
290
|
+
});
|
|
291
|
+
return {
|
|
292
|
+
initData: accountInitCallData,
|
|
293
|
+
contract: NEXUS_IMPLEMENTATION_ADDRESS,
|
|
294
|
+
};
|
|
292
295
|
}
|
|
@@ -15,11 +15,11 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
15
15
|
},
|
|
16
16
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
17
17
|
});
|
|
18
|
-
(0, vitest_1.expect)(factory).toEqual('
|
|
19
|
-
(0, vitest_1.expect)(factoryData).toEqual('
|
|
18
|
+
(0, vitest_1.expect)(factory).toEqual('0x0000000000751F0a4816c34fB95ccbD463878361');
|
|
19
|
+
(0, vitest_1.expect)(factoryData).toEqual('0xea6d13ac0000000000000000000000000000000000000000000000000000000000000040c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470000000000000000000000000000000000000000000000000000000000000036000000000000000000000000000000000001cf4667bfd7be8f67d01d63938784b000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002e441bede0300000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
20
20
|
(0, vitest_1.expect)(salt).toEqual('0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470');
|
|
21
|
-
(0, vitest_1.expect)(implementation).toEqual('
|
|
22
|
-
(0, vitest_1.expect)(initializationCallData).toEqual('
|
|
21
|
+
(0, vitest_1.expect)(implementation).toEqual('0x0000000000Fb742636364B5ca9B6D2ebbC63FB5D');
|
|
22
|
+
(0, vitest_1.expect)(initializationCallData).toEqual('0x4b6a14190000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000036000000000000000000000000000000000001cf4667bfd7be8f67d01d63938784b000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002e441bede0300000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
23
23
|
});
|
|
24
24
|
(0, vitest_1.test)('Passkey owner', () => {
|
|
25
25
|
const { factory, factoryData, salt, implementation, initializationCallData, } = (0, nexus_1.getDeployArgs)({
|
|
@@ -29,11 +29,11 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
29
29
|
},
|
|
30
30
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
31
31
|
});
|
|
32
|
-
(0, vitest_1.expect)(factory).toEqual('
|
|
33
|
-
(0, vitest_1.expect)(factoryData).toEqual('
|
|
32
|
+
(0, vitest_1.expect)(factory).toEqual('0x0000000000751F0a4816c34fB95ccbD463878361');
|
|
33
|
+
(0, vitest_1.expect)(factoryData).toEqual('0xea6d13ac0000000000000000000000000000000000000000000000000000000000000040c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47000000000000000000000000000000000000000000000000000000000000003a000000000000000000000000000000000001cf4667bfd7be8f67d01d63938784b0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000032441bede0300000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000578c4cb0e472a5462da43c495c3f3300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d19c9a01073b202db2ed56e604ad11db557d8c3ad75181619597f21b830f2da82a0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
34
34
|
(0, vitest_1.expect)(salt).toEqual('0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470');
|
|
35
|
-
(0, vitest_1.expect)(implementation).toEqual('
|
|
36
|
-
(0, vitest_1.expect)(initializationCallData).toEqual('
|
|
35
|
+
(0, vitest_1.expect)(implementation).toEqual('0x0000000000Fb742636364B5ca9B6D2ebbC63FB5D');
|
|
36
|
+
(0, vitest_1.expect)(initializationCallData).toEqual('0x4b6a1419000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000003a000000000000000000000000000000000001cf4667bfd7be8f67d01d63938784b0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000032441bede0300000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000578c4cb0e472a5462da43c495c3f3300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d19c9a01073b202db2ed56e604ad11db557d8c3ad75181619597f21b830f2da82a0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
39
|
(0, vitest_1.describe)('Get Address', () => {
|
|
@@ -45,7 +45,7 @@ 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('0xa32fa78416f6c68ce4f75f702e07849a269feffb');
|
|
49
49
|
});
|
|
50
50
|
(0, vitest_1.test)('Passkey owner', () => {
|
|
51
51
|
const address = (0, nexus_1.getAddress)({
|
|
@@ -55,7 +55,7 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
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('0xfbda4e576b2a300cd1b7e8748c9a7577ab3a503e');
|
|
59
59
|
});
|
|
60
60
|
});
|
|
61
61
|
(0, vitest_1.describe)('Get Install Data', () => {
|
|
@@ -1,9 +1,9 @@
|
|
|
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';
|
|
4
|
-
import { EnableSessionData } from '../modules/validators/smart-sessions';
|
|
3
|
+
import type { Module } from '../modules/common';
|
|
4
|
+
import type { EnableSessionData } from '../modules/validators/smart-sessions';
|
|
5
5
|
import type { OwnerSet, RhinestoneAccountConfig, Session } from '../types';
|
|
6
|
-
import { ValidatorConfig } from './utils';
|
|
6
|
+
import { type ValidatorConfig } from './utils';
|
|
7
7
|
declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
8
8
|
factory: `0x${string}`;
|
|
9
9
|
factoryData: `0x${string}`;
|
|
@@ -17,7 +17,5 @@ declare function getPackedSignature(signFn: (message: Hex) => Promise<Hex>, hash
|
|
|
17
17
|
declare function getSmartAccount(client: PublicClient, address: Address, owners: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
18
18
|
declare function getSessionSmartAccount(client: PublicClient, address: Address, session: Session, validatorAddress: Address, enableData: EnableSessionData | null, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
19
19
|
declare function getGuardianSmartAccount(client: PublicClient, address: Address, guardians: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
20
|
-
|
|
21
|
-
declare function get7702InitCalls(): never;
|
|
22
|
-
export { getInstallData, getAddress, getPackedSignature, getDeployArgs, getSmartAccount, getSessionSmartAccount, getGuardianSmartAccount, get7702InitCalls, get7702SmartAccount, };
|
|
20
|
+
export { getInstallData, getAddress, getPackedSignature, getDeployArgs, getSmartAccount, getSessionSmartAccount, getGuardianSmartAccount, };
|
|
23
21
|
//# 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,EACR,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;
|
|
1
|
+
{"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../../../accounts/safe.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EACR,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,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAQ/C,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;AAchF,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;EAiErD;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,UAAU,EAAE,iBAAiB,GAAG,IAAI,EACpC,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,iEAyClC;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;AAkGD,OAAO,EACL,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,uBAAuB,GACxB,CAAA"}
|
|
@@ -7,16 +7,13 @@ exports.getDeployArgs = getDeployArgs;
|
|
|
7
7
|
exports.getSmartAccount = getSmartAccount;
|
|
8
8
|
exports.getSessionSmartAccount = getSessionSmartAccount;
|
|
9
9
|
exports.getGuardianSmartAccount = getGuardianSmartAccount;
|
|
10
|
-
exports.get7702InitCalls = get7702InitCalls;
|
|
11
|
-
exports.get7702SmartAccount = get7702SmartAccount;
|
|
12
10
|
const viem_1 = require("viem");
|
|
13
11
|
const account_abstraction_1 = require("viem/account-abstraction");
|
|
14
12
|
const modules_1 = require("../modules");
|
|
15
13
|
const validators_1 = require("../modules/validators");
|
|
16
|
-
const error_1 = require("./error");
|
|
17
14
|
const utils_1 = require("./utils");
|
|
18
|
-
const SAFE_7579_LAUNCHPAD_ADDRESS = '
|
|
19
|
-
const SAFE_7579_ADAPTER_ADDRESS = '
|
|
15
|
+
const SAFE_7579_LAUNCHPAD_ADDRESS = '0x75798463024Bda64D83c94A64Bc7D7eaB41300eF';
|
|
16
|
+
const SAFE_7579_ADAPTER_ADDRESS = '0x7579f2AD53b01c3D8779Fe17928e0D48885B0003';
|
|
20
17
|
const SAFE_SINGLETON_ADDRESS = '0x29fcb43b46531bca003ddc8fcb67ffe91900c762';
|
|
21
18
|
const SAFE_PROXY_FACTORY_ADDRESS = '0x4e1dcf7ad4e460cfd30791ccc4f9c8a4f820ec67';
|
|
22
19
|
const NO_SAFE_OWNER_ADDRESS = '0xbabe99e62d8bcbd3acf5ccbcfcd4f64fe75e5e72';
|
|
@@ -25,6 +22,12 @@ function getDeployArgs(config) {
|
|
|
25
22
|
const owners = getOwners(config);
|
|
26
23
|
const threshold = getThreshold(config);
|
|
27
24
|
const moduleSetup = (0, modules_1.getSetup)(config);
|
|
25
|
+
const modules = [
|
|
26
|
+
...moduleSetup.validators,
|
|
27
|
+
...moduleSetup.executors,
|
|
28
|
+
...moduleSetup.fallbacks,
|
|
29
|
+
...moduleSetup.hooks,
|
|
30
|
+
];
|
|
28
31
|
const initData = (0, viem_1.encodeFunctionData)({
|
|
29
32
|
abi: (0, viem_1.parseAbi)([
|
|
30
33
|
'function setup(address[] calldata _owners,uint256 _threshold,address to,bytes calldata data,address fallbackHandler,address paymentToken,uint256 payment, address paymentReceiver) external',
|
|
@@ -36,30 +39,19 @@ function getDeployArgs(config) {
|
|
|
36
39
|
SAFE_7579_LAUNCHPAD_ADDRESS,
|
|
37
40
|
(0, viem_1.encodeFunctionData)({
|
|
38
41
|
abi: (0, viem_1.parseAbi)([
|
|
39
|
-
'struct ModuleInit {address module;bytes initData;}',
|
|
40
|
-
'function addSafe7579(address safe7579,ModuleInit[] calldata
|
|
42
|
+
'struct ModuleInit {address module;bytes initData;uint256 moduleType}',
|
|
43
|
+
'function addSafe7579(address safe7579,ModuleInit[] calldata modules,address[] calldata attesters,uint8 threshold) external',
|
|
41
44
|
]),
|
|
42
45
|
functionName: 'addSafe7579',
|
|
43
46
|
args: [
|
|
44
47
|
SAFE_7579_ADAPTER_ADDRESS,
|
|
45
|
-
|
|
46
|
-
module:
|
|
47
|
-
initData:
|
|
48
|
+
modules.map((m) => ({
|
|
49
|
+
module: m.address,
|
|
50
|
+
initData: m.initData,
|
|
51
|
+
moduleType: m.type,
|
|
48
52
|
})),
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
initData: e.initData,
|
|
52
|
-
})),
|
|
53
|
-
moduleSetup.fallbacks.map((f) => ({
|
|
54
|
-
module: f.address,
|
|
55
|
-
initData: f.initData,
|
|
56
|
-
})),
|
|
57
|
-
moduleSetup.hooks.map((h) => ({
|
|
58
|
-
module: h.address,
|
|
59
|
-
initData: h.initData,
|
|
60
|
-
})),
|
|
61
|
-
moduleSetup.attesters,
|
|
62
|
-
moduleSetup.threshold,
|
|
53
|
+
[],
|
|
54
|
+
0,
|
|
63
55
|
],
|
|
64
56
|
}),
|
|
65
57
|
SAFE_7579_ADAPTER_ADDRESS,
|
|
@@ -217,12 +209,6 @@ async function getBaseSmartAccount(address, client, validatorAddress, getStubSig
|
|
|
217
209
|
},
|
|
218
210
|
});
|
|
219
211
|
}
|
|
220
|
-
function get7702SmartAccount() {
|
|
221
|
-
throw new error_1.Eip7702NotSupportedForAccountError('safe');
|
|
222
|
-
}
|
|
223
|
-
function get7702InitCalls() {
|
|
224
|
-
throw new error_1.Eip7702NotSupportedForAccountError('safe');
|
|
225
|
-
}
|
|
226
212
|
function getOwners(config) {
|
|
227
213
|
const ownerSet = config.owners;
|
|
228
214
|
switch (ownerSet.type) {
|
|
@@ -230,6 +216,8 @@ function getOwners(config) {
|
|
|
230
216
|
return ownerSet.accounts.map((account) => account.address);
|
|
231
217
|
case 'passkey':
|
|
232
218
|
return [NO_SAFE_OWNER_ADDRESS];
|
|
219
|
+
case 'multi-factor':
|
|
220
|
+
return [NO_SAFE_OWNER_ADDRESS];
|
|
233
221
|
}
|
|
234
222
|
}
|
|
235
223
|
function getThreshold(config) {
|
|
@@ -239,5 +227,7 @@ function getThreshold(config) {
|
|
|
239
227
|
return ownerSet.threshold ? BigInt(ownerSet.threshold) : 1n;
|
|
240
228
|
case 'passkey':
|
|
241
229
|
return 1n;
|
|
230
|
+
case 'multi-factor':
|
|
231
|
+
return 1n;
|
|
242
232
|
}
|
|
243
233
|
}
|