@charterlabs/rhinestone-sdk 0.1.1 → 0.1.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/README.md +74 -181
- package/dist/src/accounts/error.d.ts +69 -0
- package/dist/src/accounts/error.d.ts.map +1 -0
- package/dist/src/accounts/error.js +109 -0
- package/dist/{accounts → src/accounts}/index.d.ts +14 -21
- package/dist/src/accounts/index.d.ts.map +1 -0
- package/dist/src/accounts/index.js +469 -0
- package/dist/src/accounts/index.test.d.ts +2 -0
- package/dist/src/accounts/index.test.d.ts.map +1 -0
- package/dist/src/accounts/index.test.js +36 -0
- package/dist/{accounts → src/accounts}/kernel.d.ts +7 -9
- package/dist/src/accounts/kernel.d.ts.map +1 -0
- package/dist/{accounts → src/accounts}/kernel.js +0 -8
- package/dist/src/accounts/kernel.test.d.ts +2 -0
- package/dist/src/accounts/kernel.test.d.ts.map +1 -0
- package/dist/src/accounts/kernel.test.js +105 -0
- package/dist/{accounts → src/accounts}/nexus.d.ts +14 -13
- package/dist/src/accounts/nexus.d.ts.map +1 -0
- package/dist/{accounts → src/accounts}/nexus.js +92 -88
- package/dist/src/accounts/nexus.test.d.ts +2 -0
- package/dist/src/accounts/nexus.test.d.ts.map +1 -0
- package/dist/src/accounts/nexus.test.js +87 -0
- package/dist/{accounts → src/accounts}/safe.d.ts +4 -6
- package/dist/src/accounts/safe.d.ts.map +1 -0
- package/dist/{accounts → src/accounts}/safe.js +20 -29
- package/dist/src/accounts/safe.test.d.ts +2 -0
- package/dist/src/accounts/safe.test.d.ts.map +1 -0
- package/dist/src/accounts/safe.test.js +87 -0
- 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 +99 -0
- package/dist/{accounts → src/accounts}/utils.d.ts +4 -3
- package/dist/src/accounts/utils.d.ts.map +1 -0
- package/dist/{accounts → src/accounts}/utils.js +44 -0
- package/dist/src/accounts/utils.test.d.ts +2 -0
- package/dist/src/accounts/utils.test.d.ts.map +1 -0
- package/dist/src/accounts/utils.test.js +49 -0
- package/dist/src/actions/index.d.ts +39 -0
- package/dist/src/actions/index.d.ts.map +1 -0
- package/dist/{actions → src/actions}/index.js +108 -15
- 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 +302 -0
- package/dist/{actions → src/actions}/smart-session.d.ts +2 -2
- package/dist/src/actions/smart-session.d.ts.map +1 -0
- package/dist/src/execution/compact.d.ts +8 -0
- package/dist/src/execution/compact.d.ts.map +1 -0
- package/dist/src/execution/compact.js +105 -0
- package/dist/src/execution/error.d.ts +54 -0
- package/dist/src/execution/error.d.ts.map +1 -0
- package/dist/src/execution/error.js +78 -0
- package/dist/{execution → src/execution}/index.d.ts +7 -6
- package/dist/src/execution/index.d.ts.map +1 -0
- package/dist/src/execution/index.js +150 -0
- package/dist/src/execution/smart-session.d.ts +15 -0
- package/dist/src/execution/smart-session.d.ts.map +1 -0
- package/dist/{execution → src/execution}/smart-session.js +16 -77
- package/dist/src/execution/smart-session.test.d.ts +2 -0
- package/dist/src/execution/smart-session.test.d.ts.map +1 -0
- package/dist/src/execution/smart-session.test.js +34 -0
- package/dist/src/execution/utils.d.ts +45 -0
- package/dist/src/execution/utils.d.ts.map +1 -0
- package/dist/src/execution/utils.js +433 -0
- package/dist/src/index.d.ts +41 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +154 -0
- package/dist/src/modules/abi/smart-sessions.d.ts.map +1 -0
- package/dist/src/modules/common.d.ts.map +1 -0
- package/dist/{modules → src/modules}/index.d.ts +3 -11
- package/dist/src/modules/index.d.ts.map +1 -0
- package/dist/{modules → src/modules}/index.js +3 -45
- package/dist/src/modules/index.test.d.ts +2 -0
- package/dist/src/modules/index.test.d.ts.map +1 -0
- package/dist/src/modules/index.test.js +107 -0
- package/dist/src/modules/omni-account.d.ts +7 -0
- package/dist/src/modules/omni-account.d.ts.map +1 -0
- package/dist/src/modules/omni-account.js +11 -0
- package/dist/src/modules/read.d.ts +9 -0
- package/dist/src/modules/read.d.ts.map +1 -0
- package/dist/{modules → src/modules}/read.js +6 -37
- package/dist/{modules → src/modules}/validators/core.d.ts +6 -7
- package/dist/src/modules/validators/core.d.ts.map +1 -0
- package/dist/{modules → src/modules}/validators/core.js +83 -8
- package/dist/src/modules/validators/core.test.d.ts +2 -0
- package/dist/src/modules/validators/core.test.d.ts.map +1 -0
- package/dist/src/modules/validators/core.test.js +108 -0
- package/dist/src/modules/validators/index.d.ts +4 -0
- package/dist/src/modules/validators/index.d.ts.map +1 -0
- package/dist/{modules → src/modules}/validators/index.js +1 -3
- package/dist/{modules → src/modules}/validators/smart-sessions.d.ts +4 -15
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -0
- package/dist/{modules → src/modules}/validators/smart-sessions.js +7 -61
- package/dist/src/modules/validators/smart-sessions.test.d.ts +2 -0
- package/dist/src/modules/validators/smart-sessions.test.d.ts.map +1 -0
- package/dist/src/modules/validators/smart-sessions.test.js +226 -0
- package/dist/src/orchestrator/client.d.ts +21 -0
- package/dist/src/orchestrator/client.d.ts.map +1 -0
- package/dist/src/orchestrator/client.js +284 -0
- package/dist/src/orchestrator/consts.d.ts +5 -0
- package/dist/src/orchestrator/consts.d.ts.map +1 -0
- package/dist/src/orchestrator/consts.js +9 -0
- package/dist/src/orchestrator/error.d.ts +96 -0
- package/dist/src/orchestrator/error.d.ts.map +1 -0
- package/dist/src/orchestrator/error.js +132 -0
- package/dist/src/orchestrator/index.d.ts +11 -0
- package/dist/src/orchestrator/index.d.ts.map +1 -0
- package/dist/src/orchestrator/index.js +42 -0
- package/dist/src/orchestrator/registry.d.ts +39 -0
- package/dist/src/orchestrator/registry.d.ts.map +1 -0
- package/dist/src/orchestrator/registry.js +121 -0
- package/dist/src/orchestrator/registry.json +365 -0
- package/dist/src/orchestrator/registry.test.d.ts +2 -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 +275 -0
- package/dist/src/orchestrator/types.d.ts.map +1 -0
- package/dist/src/orchestrator/types.js +19 -0
- package/dist/src/orchestrator/utils.d.ts +5 -0
- package/dist/src/orchestrator/utils.d.ts.map +1 -0
- package/dist/src/orchestrator/utils.js +126 -0
- package/dist/{types.d.ts → src/types.d.ts} +42 -21
- package/dist/src/types.d.ts.map +1 -0
- package/dist/test/consts.d.ts +10 -0
- package/dist/test/consts.d.ts.map +1 -0
- package/dist/test/consts.js +22 -0
- package/package.json +11 -20
- package/dist/accounts/index.d.ts.map +0 -1
- package/dist/accounts/index.js +0 -419
- package/dist/accounts/kernel.d.ts.map +0 -1
- package/dist/accounts/nexus.d.ts.map +0 -1
- package/dist/accounts/safe.d.ts.map +0 -1
- package/dist/accounts/utils.d.ts.map +0 -1
- package/dist/actions/index.d.ts +0 -29
- package/dist/actions/index.d.ts.map +0 -1
- package/dist/actions/registry.d.ts +0 -7
- package/dist/actions/registry.d.ts.map +0 -1
- package/dist/actions/registry.js +0 -7
- package/dist/actions/smart-session.d.ts.map +0 -1
- package/dist/execution/index.d.ts.map +0 -1
- package/dist/execution/index.js +0 -149
- package/dist/execution/smart-session.d.ts +0 -23
- package/dist/execution/smart-session.d.ts.map +0 -1
- package/dist/execution/utils.d.ts +0 -68
- package/dist/execution/utils.d.ts.map +0 -1
- package/dist/execution/utils.js +0 -482
- package/dist/index.d.ts +0 -38
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -119
- package/dist/modules/abi/smart-sessions.d.ts.map +0 -1
- package/dist/modules/common.d.ts.map +0 -1
- package/dist/modules/index.d.ts.map +0 -1
- package/dist/modules/omni-account.d.ts +0 -9
- package/dist/modules/omni-account.d.ts.map +0 -1
- package/dist/modules/omni-account.js +0 -15
- package/dist/modules/read.d.ts +0 -10
- package/dist/modules/read.d.ts.map +0 -1
- package/dist/modules/registry.d.ts +0 -9
- package/dist/modules/registry.d.ts.map +0 -1
- package/dist/modules/registry.js +0 -60
- package/dist/modules/validators/core.d.ts.map +0 -1
- package/dist/modules/validators/index.d.ts +0 -4
- package/dist/modules/validators/index.d.ts.map +0 -1
- package/dist/modules/validators/smart-sessions.d.ts.map +0 -1
- package/dist/orchestrator/client.d.ts +0 -29
- package/dist/orchestrator/client.d.ts.map +0 -1
- package/dist/orchestrator/client.js +0 -250
- package/dist/orchestrator/consts.d.ts +0 -5
- package/dist/orchestrator/consts.d.ts.map +0 -1
- package/dist/orchestrator/consts.js +0 -9
- package/dist/orchestrator/error.d.ts +0 -18
- package/dist/orchestrator/error.d.ts.map +0 -1
- package/dist/orchestrator/error.js +0 -33
- package/dist/orchestrator/index.d.ts +0 -11
- package/dist/orchestrator/index.d.ts.map +0 -1
- package/dist/orchestrator/index.js +0 -40
- package/dist/orchestrator/registry.d.ts +0 -20
- package/dist/orchestrator/registry.d.ts.map +0 -1
- package/dist/orchestrator/registry.js +0 -444
- package/dist/orchestrator/types.d.ts +0 -242
- package/dist/orchestrator/types.d.ts.map +0 -1
- package/dist/orchestrator/types.js +0 -19
- package/dist/orchestrator/utils.d.ts +0 -29
- package/dist/orchestrator/utils.d.ts.map +0 -1
- package/dist/orchestrator/utils.js +0 -319
- package/dist/types.d.ts.map +0 -1
- /package/dist/{actions → src/actions}/smart-session.js +0 -0
- /package/dist/{modules → src/modules}/abi/smart-sessions.d.ts +0 -0
- /package/dist/{modules → src/modules}/abi/smart-sessions.js +0 -0
- /package/dist/{modules → src/modules}/common.d.ts +0 -0
- /package/dist/{modules → src/modules}/common.js +0 -0
- /package/dist/{types.js → src/types.js} +0 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const viem_1 = require("viem");
|
|
4
|
+
const vitest_1 = require("vitest");
|
|
5
|
+
const consts_1 = require("../../test/consts");
|
|
6
|
+
const common_1 = require("../modules/common");
|
|
7
|
+
const kernel_1 = require("./kernel");
|
|
8
|
+
const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
9
|
+
(0, vitest_1.describe)('Accounts: Kernel', () => {
|
|
10
|
+
(0, vitest_1.describe)('Deploy Args', () => {
|
|
11
|
+
(0, vitest_1.test)('ECDSA owners', () => {
|
|
12
|
+
const { factory, factoryData, salt, implementation, initializationCallData, } = (0, kernel_1.getDeployArgs)({
|
|
13
|
+
owners: {
|
|
14
|
+
type: 'ecdsa',
|
|
15
|
+
accounts: [consts_1.accountA, consts_1.accountB],
|
|
16
|
+
},
|
|
17
|
+
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
18
|
+
});
|
|
19
|
+
(0, vitest_1.expect)(factory).toEqual('0xd703aae79538628d27099b8c4f621be4ccd142d5');
|
|
20
|
+
(0, vitest_1.expect)(factoryData).toEqual('0xc5265d5d0000000000000000000000002577507b78c2008ff367261cb6285d44ba5ef2e90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003243c3b752b010000000000E9E6E96Bcaa3c113187CdB7E38AED90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000094000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
21
|
+
(0, vitest_1.expect)(salt).toEqual('0x0000000000000000000000000000000000000000000000000000000000000000');
|
|
22
|
+
(0, vitest_1.expect)(implementation).toEqual('0xd6CEDDe84be40893d153Be9d467CD6aD37875b28');
|
|
23
|
+
(0, vitest_1.expect)(initializationCallData).toEqual('0x3c3b752b010000000000E9E6E96Bcaa3c113187CdB7E38AED90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
24
|
+
});
|
|
25
|
+
(0, vitest_1.test)('Passkey owner', () => {
|
|
26
|
+
const { factory, factoryData, salt, implementation, initializationCallData, } = (0, kernel_1.getDeployArgs)({
|
|
27
|
+
owners: {
|
|
28
|
+
type: 'passkey',
|
|
29
|
+
account: consts_1.passkeyAccount,
|
|
30
|
+
credentialIds: ['0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'],
|
|
31
|
+
},
|
|
32
|
+
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
33
|
+
});
|
|
34
|
+
(0, vitest_1.expect)(factory).toEqual('0xd703aae79538628d27099b8c4f621be4ccd142d5');
|
|
35
|
+
(0, vitest_1.expect)(factoryData).toEqual('0xc5265d5d0000000000000000000000002577507b78c2008ff367261cb6285d44ba5ef2e90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e43c3b752b010000000000578c4cB0e472a5462da43C495C3F330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000060580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d19c9a01073b202db2ed56e604ad11db557d8c3ad75181619597f21b830f2da82a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000094000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
36
|
+
(0, vitest_1.expect)(salt).toEqual('0x0000000000000000000000000000000000000000000000000000000000000000');
|
|
37
|
+
(0, vitest_1.expect)(implementation).toEqual('0xd6CEDDe84be40893d153Be9d467CD6aD37875b28');
|
|
38
|
+
(0, vitest_1.expect)(initializationCallData).toEqual('0x3c3b752b010000000000578c4cB0e472a5462da43C495C3F330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000060580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d19c9a01073b202db2ed56e604ad11db557d8c3ad75181619597f21b830f2da82a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
(0, vitest_1.describe)('Get Address', () => {
|
|
42
|
+
(0, vitest_1.test)('ECDSA owners', () => {
|
|
43
|
+
const address = (0, kernel_1.getAddress)({
|
|
44
|
+
owners: {
|
|
45
|
+
type: 'ecdsa',
|
|
46
|
+
accounts: [consts_1.accountA, consts_1.accountB],
|
|
47
|
+
},
|
|
48
|
+
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
49
|
+
});
|
|
50
|
+
(0, vitest_1.expect)(address).toEqual('0xe4090134D2FdC0fc13b43651B5b1c75BDf825c5f');
|
|
51
|
+
});
|
|
52
|
+
(0, vitest_1.test)('Passkey owner', () => {
|
|
53
|
+
const address = (0, kernel_1.getAddress)({
|
|
54
|
+
owners: {
|
|
55
|
+
type: 'passkey',
|
|
56
|
+
account: consts_1.passkeyAccount,
|
|
57
|
+
credentialIds: ['0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'],
|
|
58
|
+
},
|
|
59
|
+
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
60
|
+
});
|
|
61
|
+
(0, vitest_1.expect)(address).toEqual('0x5a4063A8f32201C84B8e7a073C7494D53D7dFAe7');
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
(0, vitest_1.describe)('Get Install Data', () => {
|
|
65
|
+
(0, vitest_1.test)('Module', () => {
|
|
66
|
+
const installData = (0, kernel_1.getInstallData)({
|
|
67
|
+
address: MOCK_MODULE_ADDRESS,
|
|
68
|
+
initData: '0xabcd',
|
|
69
|
+
type: common_1.MODULE_TYPE_ID_VALIDATOR,
|
|
70
|
+
deInitData: '0x0000',
|
|
71
|
+
additionalContext: '0x0000',
|
|
72
|
+
});
|
|
73
|
+
(0, vitest_1.expect)(installData).toEqual([
|
|
74
|
+
'0x9517e29f000000000000000000000000000000000000000000000000000000000000000100000000000000000000000028de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000f40000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000002abcd00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
|
75
|
+
'0xb9b829410128de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f0000000000000000000000e9ae5c53000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001',
|
|
76
|
+
]);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
(0, vitest_1.describe)('Get Packed Signature', () => {
|
|
80
|
+
(0, vitest_1.describe)('Mock signature', () => {
|
|
81
|
+
(0, vitest_1.test)('Root validator', async () => {
|
|
82
|
+
const hash = (0, viem_1.keccak256)('0xabcd');
|
|
83
|
+
const mockSignature = '0x1234';
|
|
84
|
+
const accountAddress = '0xa80ed905adbd7cba128aaf64a1fa33a530b9b0aa';
|
|
85
|
+
const validator = {
|
|
86
|
+
address: '0xe35b75e5ec3c04e9cefa8e581fbee859f56edeb4',
|
|
87
|
+
isRoot: true,
|
|
88
|
+
};
|
|
89
|
+
const signature = await (0, kernel_1.getPackedSignature)(async (_) => mockSignature, hash, validator, accountAddress);
|
|
90
|
+
(0, vitest_1.expect)(signature).toEqual('0x000555ad2729e8da1777a4e5020806f8bf7601c3db6bfe402f410a34958363a95a1234');
|
|
91
|
+
});
|
|
92
|
+
(0, vitest_1.test)('Non-root validator', async () => {
|
|
93
|
+
const hash = (0, viem_1.keccak256)('0xabcd');
|
|
94
|
+
const mockSignature = '0x1234';
|
|
95
|
+
const accountAddress = '0xa80ed905adbd7cba128aaf64a1fa33a530b9b0aa';
|
|
96
|
+
const validator = {
|
|
97
|
+
address: '0xe35b75e5ec3c04e9cefa8e581fbee859f56edeb4',
|
|
98
|
+
isRoot: false,
|
|
99
|
+
};
|
|
100
|
+
const signature = await (0, kernel_1.getPackedSignature)(async (_) => mockSignature, hash, validator, accountAddress);
|
|
101
|
+
(0, vitest_1.expect)(signature).toEqual('0x01e35b75e5ec3c04e9cefa8e581fbee859f56edeb40555ad2729e8da1777a4e5020806f8bf7601c3db6bfe402f410a34958363a95a1234');
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
});
|
|
@@ -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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nexus.d.ts","sourceRoot":"","sources":["../../../accounts/nexus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAYpE,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAEhC,MAAM,0BAA0B,CAAA;AAGjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAS/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAC7E,OAAO,KAAK,EAAE,QAAQ,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAE1E,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;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,33 +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");
|
|
17
|
+
const error_1 = require("./error");
|
|
16
18
|
const utils_1 = require("./utils");
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
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';
|
|
21
23
|
const NEXUS_CREATION_CODE = '0x60806040526102aa803803806100148161018c565b92833981016040828203126101885781516001600160a01b03811692909190838303610188576020810151906001600160401b03821161018857019281601f8501121561018857835161006e610069826101c5565b61018c565b9481865260208601936020838301011161018857815f926020809301865e8601015260017f90b772c2cb8a51aa7a8a65fc23543c6d022d5b3f8e2b92eed79fba7eef8293005d823b15610176577f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b031916821790557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b5f80a282511561015e575f8091610146945190845af43d15610156573d91610137610069846101c5565b9283523d5f602085013e6101e0565b505b604051606b908161023f8239f35b6060916101e0565b50505034156101485763b398979f60e01b5f5260045ffd5b634c9c8ce360e01b5f5260045260245ffd5b5f80fd5b6040519190601f01601f191682016001600160401b038111838210176101b157604052565b634e487b7160e01b5f52604160045260245ffd5b6001600160401b0381116101b157601f01601f191660200190565b9061020457508051156101f557805190602001fd5b63d6bda27560e01b5f5260045ffd5b81511580610235575b610215575090565b639996b31560e01b5f9081526001600160a01b0391909116600452602490fd5b50803b1561020d56fe60806040523615605c575f8073ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416368280378136915af43d5f803e156058573d5ff35b3d5ffd5b00fea164736f6c634300081b000a';
|
|
22
24
|
function getDeployArgs(config) {
|
|
23
25
|
const salt = (0, viem_1.keccak256)('0x');
|
|
24
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);
|
|
25
33
|
const initData = (0, viem_1.encodeAbiParameters)([{ type: 'address' }, { type: 'bytes' }], [
|
|
26
34
|
NEXUS_BOOTSTRAP_ADDRESS,
|
|
27
35
|
(0, viem_1.encodeFunctionData)({
|
|
28
36
|
abi: (0, viem_1.parseAbi)([
|
|
29
37
|
'struct BootstrapConfig {address module;bytes initData;}',
|
|
30
38
|
'struct BootstrapPreValidationHookConfig {uint256 hookType;address module;bytes data;}',
|
|
31
|
-
'
|
|
32
|
-
'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',
|
|
33
40
|
]),
|
|
34
|
-
functionName: '
|
|
41
|
+
functionName: 'initNexusWithDefaultValidatorAndOtherModulesNoRegistry',
|
|
35
42
|
args: [
|
|
36
|
-
|
|
43
|
+
defaultValidatorInitData,
|
|
44
|
+
validators.map((v) => ({
|
|
37
45
|
module: v.address,
|
|
38
46
|
initData: v.initData,
|
|
39
47
|
})),
|
|
@@ -50,11 +58,6 @@ function getDeployArgs(config) {
|
|
|
50
58
|
initData: f.initData,
|
|
51
59
|
})),
|
|
52
60
|
[],
|
|
53
|
-
{
|
|
54
|
-
registry: moduleSetup.registry,
|
|
55
|
-
attesters: moduleSetup.attesters,
|
|
56
|
-
threshold: moduleSetup.threshold,
|
|
57
|
-
},
|
|
58
61
|
],
|
|
59
62
|
}),
|
|
60
63
|
]);
|
|
@@ -74,6 +77,7 @@ function getDeployArgs(config) {
|
|
|
74
77
|
salt,
|
|
75
78
|
implementation: NEXUS_IMPLEMENTATION_ADDRESS,
|
|
76
79
|
initializationCallData,
|
|
80
|
+
initData,
|
|
77
81
|
};
|
|
78
82
|
}
|
|
79
83
|
function getAddress(config) {
|
|
@@ -121,17 +125,20 @@ function getInstallData(module) {
|
|
|
121
125
|
args: [module.type, module.address, module.initData],
|
|
122
126
|
});
|
|
123
127
|
}
|
|
124
|
-
async function getPackedSignature(signFn, hash, validator, transformSignature = (signature) => signature) {
|
|
128
|
+
async function getPackedSignature(signFn, hash, validator, transformSignature = (signature) => signature, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
|
|
125
129
|
const signature = await signFn(hash);
|
|
126
|
-
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)]);
|
|
127
134
|
return packedSig;
|
|
128
135
|
}
|
|
129
|
-
async function getSmartAccount(client, address, owners, validatorAddress, sign) {
|
|
136
|
+
async function getSmartAccount(client, address, owners, validatorAddress, sign, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
|
|
130
137
|
return getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
131
138
|
return (0, validators_1.getMockSignature)(owners);
|
|
132
|
-
}, sign);
|
|
139
|
+
}, sign, defaultValidatorAddress);
|
|
133
140
|
}
|
|
134
|
-
async function getSessionSmartAccount(client, address, session, validatorAddress, enableData, sign) {
|
|
141
|
+
async function getSessionSmartAccount(client, address, session, validatorAddress, enableData, sign, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
|
|
135
142
|
return await getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
136
143
|
const dummyOpSignature = (0, validators_1.getMockSignature)(session.owners);
|
|
137
144
|
if (enableData) {
|
|
@@ -144,29 +151,16 @@ async function getSessionSmartAccount(client, address, session, validatorAddress
|
|
|
144
151
|
return (0, validators_1.encodeSmartSessionSignature)(validators_1.SMART_SESSION_MODE_ENABLE, (0, validators_1.getPermissionId)(session), signature, enableData);
|
|
145
152
|
}
|
|
146
153
|
return (0, validators_1.encodeSmartSessionSignature)(validators_1.SMART_SESSION_MODE_USE, (0, validators_1.getPermissionId)(session), signature);
|
|
147
|
-
});
|
|
154
|
+
}, defaultValidatorAddress);
|
|
148
155
|
}
|
|
149
|
-
async function getGuardianSmartAccount(client, address, guardians, validatorAddress, sign) {
|
|
156
|
+
async function getGuardianSmartAccount(client, address, guardians, validatorAddress, sign, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
|
|
150
157
|
return await getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
151
158
|
return (0, validators_1.getMockSignature)(guardians);
|
|
152
159
|
}, async (hash) => {
|
|
153
160
|
return await sign(hash);
|
|
154
|
-
});
|
|
161
|
+
}, defaultValidatorAddress);
|
|
155
162
|
}
|
|
156
|
-
async function
|
|
157
|
-
return await getBaseSmartAccount(account.address, client, viem_1.zeroAddress, async () => {
|
|
158
|
-
const dynamicPart = K1_MEE_VALIDATOR_ADDRESS.substring(2).padEnd(40, '0');
|
|
159
|
-
return `0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000${dynamicPart}000000000000000000000000000000000000000000000000000000000000004181d4b4981670cb18f99f0b4a66446df1bf5b204d24cfcb659bf38ba27a4359b5711649ec2423c5e1247245eba2964679b6a1dbb85c992ae40b9b00c6935b02ff1b00000000000000000000000000000000000000000000000000000000000000`;
|
|
160
|
-
}, async (hash) => {
|
|
161
|
-
if (!account.signMessage) {
|
|
162
|
-
throw new Error('Sign message not supported by account');
|
|
163
|
-
}
|
|
164
|
-
return await account.signMessage({
|
|
165
|
-
message: { raw: hash },
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
async function getBaseSmartAccount(address, client, nonceValidatorAddress, getStubSignature, signUserOperation) {
|
|
163
|
+
async function getBaseSmartAccount(address, client, nonceValidatorAddress, getStubSignature, signUserOperation, defaultValidatorAddress) {
|
|
170
164
|
return await (0, account_abstraction_1.toSmartAccount)({
|
|
171
165
|
client,
|
|
172
166
|
entryPoint: {
|
|
@@ -195,13 +189,16 @@ async function getBaseSmartAccount(address, client, nonceValidatorAddress, getSt
|
|
|
195
189
|
return {};
|
|
196
190
|
},
|
|
197
191
|
async getNonce(args) {
|
|
192
|
+
const validatorAddress = nonceValidatorAddress === defaultValidatorAddress
|
|
193
|
+
? viem_1.zeroAddress
|
|
194
|
+
: nonceValidatorAddress;
|
|
198
195
|
const TIMESTAMP_ADJUSTMENT = 16777215n; // max value for size 3
|
|
199
196
|
const defaultedKey = (args?.key ?? 0n) % TIMESTAMP_ADJUSTMENT;
|
|
200
197
|
const defaultedValidationMode = '0x00';
|
|
201
198
|
const key = (0, viem_1.concat)([
|
|
202
199
|
(0, viem_1.toHex)(defaultedKey, { size: 3 }),
|
|
203
200
|
defaultedValidationMode,
|
|
204
|
-
|
|
201
|
+
validatorAddress,
|
|
205
202
|
]);
|
|
206
203
|
return (0, utils_1.getAccountNonce)(client, {
|
|
207
204
|
address,
|
|
@@ -236,56 +233,63 @@ async function getBaseSmartAccount(address, client, nonceValidatorAddress, getSt
|
|
|
236
233
|
},
|
|
237
234
|
});
|
|
238
235
|
}
|
|
239
|
-
function
|
|
240
|
-
const
|
|
241
|
-
if (!eoa) {
|
|
242
|
-
throw new
|
|
236
|
+
async function signEip7702InitData(config, eoa) {
|
|
237
|
+
const { initData } = getDeployArgs(config);
|
|
238
|
+
if (!eoa.signTypedData) {
|
|
239
|
+
throw new error_1.SigningNotSupportedForAccountError();
|
|
243
240
|
}
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
moduleSetup.attesters,
|
|
256
|
-
moduleSetup.threshold,
|
|
257
|
-
],
|
|
258
|
-
}),
|
|
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
|
+
],
|
|
259
252
|
},
|
|
260
|
-
|
|
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
|
-
|
|
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
|
+
};
|
|
291
295
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nexus.test.d.ts","sourceRoot":"","sources":["../../../accounts/nexus.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const consts_1 = require("../../test/consts");
|
|
5
|
+
const common_1 = require("../modules/common");
|
|
6
|
+
const nexus_1 = require("./nexus");
|
|
7
|
+
const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
8
|
+
(0, vitest_1.describe)('Accounts: Nexus', () => {
|
|
9
|
+
(0, vitest_1.describe)('Deploy Args', () => {
|
|
10
|
+
(0, vitest_1.test)('ECDSA owners', () => {
|
|
11
|
+
const { factory, factoryData, salt, implementation, initializationCallData, } = (0, nexus_1.getDeployArgs)({
|
|
12
|
+
owners: {
|
|
13
|
+
type: 'ecdsa',
|
|
14
|
+
accounts: [consts_1.accountA, consts_1.accountB],
|
|
15
|
+
},
|
|
16
|
+
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
17
|
+
});
|
|
18
|
+
(0, vitest_1.expect)(factory).toEqual('0x0000000000751F0a4816c34fB95ccbD463878361');
|
|
19
|
+
(0, vitest_1.expect)(factoryData).toEqual('0xea6d13ac0000000000000000000000000000000000000000000000000000000000000040c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470000000000000000000000000000000000000000000000000000000000000036000000000000000000000000000000000001cf4667bfd7be8f67d01d63938784b000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002e441bede0300000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
20
|
+
(0, vitest_1.expect)(salt).toEqual('0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470');
|
|
21
|
+
(0, vitest_1.expect)(implementation).toEqual('0x0000000000Fb742636364B5ca9B6D2ebbC63FB5D');
|
|
22
|
+
(0, vitest_1.expect)(initializationCallData).toEqual('0x4b6a14190000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000036000000000000000000000000000000000001cf4667bfd7be8f67d01d63938784b000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002e441bede0300000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
23
|
+
});
|
|
24
|
+
(0, vitest_1.test)('Passkey owner', () => {
|
|
25
|
+
const { factory, factoryData, salt, implementation, initializationCallData, } = (0, nexus_1.getDeployArgs)({
|
|
26
|
+
owners: {
|
|
27
|
+
type: 'passkey',
|
|
28
|
+
account: consts_1.passkeyAccount,
|
|
29
|
+
credentialIds: ['0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'],
|
|
30
|
+
},
|
|
31
|
+
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
32
|
+
});
|
|
33
|
+
(0, vitest_1.expect)(factory).toEqual('0x0000000000751F0a4816c34fB95ccbD463878361');
|
|
34
|
+
(0, vitest_1.expect)(factoryData).toEqual('0xea6d13ac0000000000000000000000000000000000000000000000000000000000000040c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47000000000000000000000000000000000000000000000000000000000000003a000000000000000000000000000000000001cf4667bfd7be8f67d01d63938784b0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000032441bede0300000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000578c4cb0e472a5462da43c495c3f3300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d19c9a01073b202db2ed56e604ad11db557d8c3ad75181619597f21b830f2da82a0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
35
|
+
(0, vitest_1.expect)(salt).toEqual('0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470');
|
|
36
|
+
(0, vitest_1.expect)(implementation).toEqual('0x0000000000Fb742636364B5ca9B6D2ebbC63FB5D');
|
|
37
|
+
(0, vitest_1.expect)(initializationCallData).toEqual('0x4b6a1419000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000003a000000000000000000000000000000000001cf4667bfd7be8f67d01d63938784b0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000032441bede0300000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000028000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000578c4cb0e472a5462da43c495c3f3300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d19c9a01073b202db2ed56e604ad11db557d8c3ad75181619597f21b830f2da82a0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
(0, vitest_1.describe)('Get Address', () => {
|
|
41
|
+
(0, vitest_1.test)('ECDSA owners', () => {
|
|
42
|
+
const address = (0, nexus_1.getAddress)({
|
|
43
|
+
owners: {
|
|
44
|
+
type: 'ecdsa',
|
|
45
|
+
accounts: [consts_1.accountA, consts_1.accountB],
|
|
46
|
+
},
|
|
47
|
+
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
48
|
+
});
|
|
49
|
+
(0, vitest_1.expect)(address).toEqual('0xa32fa78416f6c68ce4f75f702e07849a269feffb');
|
|
50
|
+
});
|
|
51
|
+
(0, vitest_1.test)('Passkey owner', () => {
|
|
52
|
+
const address = (0, nexus_1.getAddress)({
|
|
53
|
+
owners: {
|
|
54
|
+
type: 'passkey',
|
|
55
|
+
account: consts_1.passkeyAccount,
|
|
56
|
+
credentialIds: ['0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'],
|
|
57
|
+
},
|
|
58
|
+
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
59
|
+
});
|
|
60
|
+
(0, vitest_1.expect)(address).toEqual('0xfbda4e576b2a300cd1b7e8748c9a7577ab3a503e');
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
(0, vitest_1.describe)('Get Install Data', () => {
|
|
64
|
+
(0, vitest_1.test)('Module', () => {
|
|
65
|
+
const installData = (0, nexus_1.getInstallData)({
|
|
66
|
+
address: MOCK_MODULE_ADDRESS,
|
|
67
|
+
initData: '0xabcd',
|
|
68
|
+
type: common_1.MODULE_TYPE_ID_VALIDATOR,
|
|
69
|
+
deInitData: '0x0000',
|
|
70
|
+
additionalContext: '0x0000',
|
|
71
|
+
});
|
|
72
|
+
(0, vitest_1.expect)(installData).toEqual('0x9517e29f000000000000000000000000000000000000000000000000000000000000000100000000000000000000000028de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000002abcd000000000000000000000000000000000000000000000000000000000000');
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
(0, vitest_1.describe)('Get Packed Signature', () => {
|
|
76
|
+
(0, vitest_1.test)('Mock signature', async () => {
|
|
77
|
+
const hash = '0xabcd';
|
|
78
|
+
const mockSignature = '0x1234';
|
|
79
|
+
const validator = {
|
|
80
|
+
address: '0xe35b75e5ec3c04e9cefa8e581fbee859f56edeb4',
|
|
81
|
+
isRoot: true,
|
|
82
|
+
};
|
|
83
|
+
const signature = await (0, nexus_1.getPackedSignature)(async (_) => mockSignature, hash, validator);
|
|
84
|
+
(0, vitest_1.expect)(signature).toEqual('0xe35b75e5ec3c04e9cefa8e581fbee859f56edeb41234');
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -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
|
|
@@ -0,0 +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,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"}
|