@rhinestone/sdk 1.0.0-alpha.2 → 1.0.0-alpha.21
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/custom.d.ts +18 -0
- package/dist/src/accounts/custom.d.ts.map +1 -0
- package/dist/src/accounts/custom.js +121 -0
- package/dist/src/accounts/custom.test.d.ts +2 -0
- package/dist/src/accounts/custom.test.d.ts.map +1 -0
- package/dist/src/accounts/custom.test.js +64 -0
- 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 +22 -13
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +192 -186
- package/dist/src/accounts/index.test.js +3 -3
- package/dist/src/accounts/json-rpc/index.d.ts +5 -0
- package/dist/src/accounts/json-rpc/index.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/index.js +16 -0
- package/dist/src/accounts/json-rpc/index.test.d.ts +2 -0
- package/dist/src/accounts/json-rpc/index.test.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/index.test.js +16 -0
- package/dist/src/accounts/json-rpc/providers.d.ts +4 -0
- package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/providers.js +14 -0
- package/dist/src/accounts/json-rpc/providers.test.d.ts +2 -0
- package/dist/src/accounts/json-rpc/providers.test.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/providers.test.js +15 -0
- package/dist/src/accounts/kernel.d.ts +9 -10
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +3 -14
- package/dist/src/accounts/kernel.test.js +10 -15
- 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 +121 -93
- package/dist/src/accounts/nexus.test.js +13 -14
- package/dist/src/accounts/safe.d.ts +5 -7
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +25 -35
- package/dist/src/accounts/safe.test.js +9 -10
- package/dist/src/accounts/signing/common.d.ts +27 -0
- package/dist/src/accounts/signing/common.d.ts.map +1 -0
- package/dist/src/accounts/signing/common.js +142 -0
- package/dist/src/accounts/signing/message.d.ts +5 -0
- package/dist/src/accounts/signing/message.d.ts.map +1 -0
- package/dist/src/accounts/signing/message.js +47 -0
- package/dist/src/accounts/signing/passkeys.d.ts +29 -0
- package/dist/src/accounts/signing/passkeys.d.ts.map +1 -0
- package/dist/src/accounts/signing/passkeys.js +90 -0
- package/dist/src/accounts/signing/passkeys.test.d.ts +2 -0
- package/dist/src/accounts/signing/passkeys.test.d.ts.map +1 -0
- package/dist/src/accounts/signing/passkeys.test.js +73 -0
- package/dist/src/accounts/signing/typedData.d.ts +5 -0
- package/dist/src/accounts/signing/typedData.d.ts.map +1 -0
- package/dist/src/accounts/signing/typedData.js +35 -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 +96 -0
- package/dist/src/accounts/utils.d.ts +2 -1
- package/dist/src/accounts/utils.d.ts.map +1 -1
- package/dist/src/accounts/utils.js +7 -0
- package/dist/src/actions/index.d.ts +145 -7
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +373 -23
- package/dist/src/actions/index.test.js +35 -17
- package/dist/src/actions/smart-session.d.ts +8 -2
- package/dist/src/actions/smart-session.d.ts.map +1 -1
- package/dist/src/actions/smart-session.js +6 -0
- package/dist/src/execution/compact.d.ts +130 -3
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +94 -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 +3 -4
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +35 -80
- 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 +19 -14
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +222 -97
- package/dist/src/index.d.ts +17 -15
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +108 -21
- package/dist/src/modules/index.d.ts +3 -22
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +5 -65
- package/dist/src/modules/index.test.js +3 -17
- package/dist/src/modules/omni-account.d.ts +2 -4
- package/dist/src/modules/omni-account.d.ts.map +1 -1
- package/dist/src/modules/omni-account.js +4 -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 +7 -37
- package/dist/src/modules/validators/core.d.ts +8 -8
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +126 -42
- package/dist/src/modules/validators/core.test.js +7 -7
- 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 +10 -9
- package/dist/src/modules/validators/smart-sessions.test.js +4 -4
- package/dist/src/orchestrator/client.d.ts +5 -3
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +159 -95
- package/dist/src/orchestrator/consts.d.ts +3 -2
- package/dist/src/orchestrator/consts.d.ts.map +1 -1
- package/dist/src/orchestrator/consts.js +4 -2
- package/dist/src/orchestrator/index.d.ts +3 -4
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +1 -9
- package/dist/src/orchestrator/registry.d.ts +10 -13
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +75 -395
- 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 +78 -16
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/orchestrator/utils.d.ts +1 -3
- package/dist/src/orchestrator/utils.d.ts.map +1 -1
- package/dist/src/orchestrator/utils.js +0 -102
- package/dist/src/types.d.ts +69 -26
- 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 +2 -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
|
@@ -15,25 +15,25 @@ 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('0x0000000000679A258c64d2F20F310e12B64b7375');
|
|
19
|
+
(0, vitest_1.expect)(factoryData).toEqual('0xea6d13ac0000000000000000000000000000000000000000000000000000000000000040c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470000000000000000000000000000000000000000000000000000000000000036000000000000000000000000000000000006efb61d8c9546ff1b500de3f244ea7000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002e441bede0300000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
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('0x000000000032dDC454C3BDcba80484Ad5A798705');
|
|
22
|
+
(0, vitest_1.expect)(initializationCallData).toEqual('0x4b6a14190000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000036000000000000000000000000000000000006efb61d8c9546ff1b500de3f244ea7000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002e441bede0300000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
23
23
|
});
|
|
24
24
|
(0, vitest_1.test)('Passkey owner', () => {
|
|
25
25
|
const { factory, factoryData, salt, implementation, initializationCallData, } = (0, nexus_1.getDeployArgs)({
|
|
26
26
|
owners: {
|
|
27
27
|
type: 'passkey',
|
|
28
|
-
|
|
28
|
+
accounts: [consts_1.passkeyAccount],
|
|
29
29
|
},
|
|
30
30
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
31
31
|
});
|
|
32
|
-
(0, vitest_1.expect)(factory).toEqual('
|
|
33
|
-
(0, vitest_1.expect)(factoryData).toEqual('
|
|
32
|
+
(0, vitest_1.expect)(factory).toEqual('0x0000000000679A258c64d2F20F310e12B64b7375');
|
|
33
|
+
(0, vitest_1.expect)(factoryData).toEqual('0xea6d13ac0000000000000000000000000000000000000000000000000000000000000040c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000006efb61d8c9546ff1b500de3f244ea7000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000003448643787600000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000578c4cb0e472a5462da43c495c3f33000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
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('0x000000000032dDC454C3BDcba80484Ad5A798705');
|
|
36
|
+
(0, vitest_1.expect)(initializationCallData).toEqual('0x4b6a1419000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000006efb61d8c9546ff1b500de3f244ea7000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000003448643787600000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000578c4cb0e472a5462da43c495c3f33000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
39
|
(0, vitest_1.describe)('Get Address', () => {
|
|
@@ -45,17 +45,17 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
45
45
|
},
|
|
46
46
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
47
47
|
});
|
|
48
|
-
(0, vitest_1.expect)(address).toEqual('
|
|
48
|
+
(0, vitest_1.expect)(address).toEqual('0x0681de31e060b384f0b08a3bac99e9bdff302474');
|
|
49
49
|
});
|
|
50
50
|
(0, vitest_1.test)('Passkey owner', () => {
|
|
51
51
|
const address = (0, nexus_1.getAddress)({
|
|
52
52
|
owners: {
|
|
53
53
|
type: 'passkey',
|
|
54
|
-
|
|
54
|
+
accounts: [consts_1.passkeyAccount],
|
|
55
55
|
},
|
|
56
56
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
57
57
|
});
|
|
58
|
-
(0, vitest_1.expect)(address).toEqual('
|
|
58
|
+
(0, vitest_1.expect)(address).toEqual('0x894b88c04b4de6abddce81e8bdc91927e37d6ced');
|
|
59
59
|
});
|
|
60
60
|
});
|
|
61
61
|
(0, vitest_1.describe)('Get Install Data', () => {
|
|
@@ -72,13 +72,12 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
72
72
|
});
|
|
73
73
|
(0, vitest_1.describe)('Get Packed Signature', () => {
|
|
74
74
|
(0, vitest_1.test)('Mock signature', async () => {
|
|
75
|
-
const hash = '0xabcd';
|
|
76
75
|
const mockSignature = '0x1234';
|
|
77
76
|
const validator = {
|
|
78
77
|
address: '0xe35b75e5ec3c04e9cefa8e581fbee859f56edeb4',
|
|
79
78
|
isRoot: true,
|
|
80
79
|
};
|
|
81
|
-
const signature = await (0, nexus_1.
|
|
80
|
+
const signature = await (0, nexus_1.packSignature)(mockSignature, validator);
|
|
82
81
|
(0, vitest_1.expect)(signature).toEqual('0xe35b75e5ec3c04e9cefa8e581fbee859f56edeb41234');
|
|
83
82
|
});
|
|
84
83
|
});
|
|
@@ -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}`;
|
|
@@ -13,11 +13,9 @@ declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
|
13
13
|
};
|
|
14
14
|
declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
|
|
15
15
|
declare function getInstallData(module: Module): `0x${string}`;
|
|
16
|
-
declare function
|
|
16
|
+
declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
|
|
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, packSignature, 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,aAAa,CAC1B,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,eAAe,EAC1B,kBAAkB,GAAE,CAAC,SAAS,EAAE,GAAG,KAAK,GAA8B,0BAMvE;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;AAoGD,OAAO,EACL,cAAc,EACd,UAAU,EACV,aAAa,EACb,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,uBAAuB,GACxB,CAAA"}
|
|
@@ -2,21 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getInstallData = getInstallData;
|
|
4
4
|
exports.getAddress = getAddress;
|
|
5
|
-
exports.
|
|
5
|
+
exports.packSignature = packSignature;
|
|
6
6
|
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,
|
|
@@ -121,10 +113,8 @@ function getInstallData(module) {
|
|
|
121
113
|
args: [module.type, module.address, module.initData],
|
|
122
114
|
});
|
|
123
115
|
}
|
|
124
|
-
async function
|
|
125
|
-
|
|
126
|
-
const packedSig = (0, viem_1.encodePacked)(['address', 'bytes'], [validator.address, transformSignature(signature)]);
|
|
127
|
-
return packedSig;
|
|
116
|
+
async function packSignature(signature, validator, transformSignature = (signature) => signature) {
|
|
117
|
+
return (0, viem_1.encodePacked)(['address', 'bytes'], [validator.address, transformSignature(signature)]);
|
|
128
118
|
}
|
|
129
119
|
async function getSmartAccount(client, address, owners, validatorAddress, sign) {
|
|
130
120
|
return getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
@@ -217,27 +207,27 @@ async function getBaseSmartAccount(address, client, validatorAddress, getStubSig
|
|
|
217
207
|
},
|
|
218
208
|
});
|
|
219
209
|
}
|
|
220
|
-
function get7702SmartAccount() {
|
|
221
|
-
throw new error_1.Eip7702NotSupportedForAccountError('safe');
|
|
222
|
-
}
|
|
223
|
-
function get7702InitCalls() {
|
|
224
|
-
throw new error_1.Eip7702NotSupportedForAccountError('safe');
|
|
225
|
-
}
|
|
226
210
|
function getOwners(config) {
|
|
227
211
|
const ownerSet = config.owners;
|
|
228
212
|
switch (ownerSet.type) {
|
|
229
213
|
case 'ecdsa':
|
|
214
|
+
case 'ecdsa-v0':
|
|
230
215
|
return ownerSet.accounts.map((account) => account.address);
|
|
231
216
|
case 'passkey':
|
|
232
217
|
return [NO_SAFE_OWNER_ADDRESS];
|
|
218
|
+
case 'multi-factor':
|
|
219
|
+
return [NO_SAFE_OWNER_ADDRESS];
|
|
233
220
|
}
|
|
234
221
|
}
|
|
235
222
|
function getThreshold(config) {
|
|
236
223
|
const ownerSet = config.owners;
|
|
237
224
|
switch (ownerSet.type) {
|
|
238
225
|
case 'ecdsa':
|
|
226
|
+
case 'ecdsa-v0':
|
|
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
|
}
|
|
@@ -16,8 +16,8 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
16
16
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
17
17
|
});
|
|
18
18
|
(0, vitest_1.expect)(factory).toEqual('0x4e1dcf7ad4e460cfd30791ccc4f9c8a4f820ec67');
|
|
19
|
-
(0, vitest_1.expect)(factoryData).toEqual('
|
|
20
|
-
(0, vitest_1.expect)(salt).toEqual('
|
|
19
|
+
(0, vitest_1.expect)(factoryData).toEqual('0x1688f0b900000000000000000000000029fcb43b46531bca003ddc8fcb67ffe91900c762000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000444b63e800d0000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000075798463024bda64d83c94a64bc7d7eab41300ef00000000000000000000000000000000000000000000000000000000000001600000000000000000000000007579f2ad53b01c3d8779fe17928e0d48885b00030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000f6c02c78ded62973b43bfa523b247da0994869360000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb700000000000000000000000000000000000000000000000000000000000002a447cbbdca0000000000000000000000007579f2ad53b01c3d8779fe17928e0d48885b0003000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000013fdb5234e4e3162a810f54d9f7e980000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
20
|
+
(0, vitest_1.expect)(salt).toEqual('0xf31933c8d3ab801f5d7dbfd374464b228d509d625a72334e218cbe08be7716e6');
|
|
21
21
|
(0, vitest_1.expect)(implementation).toEqual('0x29fcb43b46531bca003ddc8fcb67ffe91900c762');
|
|
22
22
|
(0, vitest_1.expect)(initializationCallData).toEqual(null);
|
|
23
23
|
});
|
|
@@ -25,13 +25,13 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
25
25
|
const { factory, factoryData, salt, implementation, initializationCallData, } = (0, safe_1.getDeployArgs)({
|
|
26
26
|
owners: {
|
|
27
27
|
type: 'passkey',
|
|
28
|
-
|
|
28
|
+
accounts: [consts_1.passkeyAccount],
|
|
29
29
|
},
|
|
30
30
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
31
31
|
});
|
|
32
32
|
(0, vitest_1.expect)(factory).toEqual('0x4e1dcf7ad4e460cfd30791ccc4f9c8a4f820ec67');
|
|
33
|
-
(0, vitest_1.expect)(factoryData).toEqual('
|
|
34
|
-
(0, vitest_1.expect)(salt).toEqual('
|
|
33
|
+
(0, vitest_1.expect)(factoryData).toEqual('0x1688f0b900000000000000000000000029fcb43b46531bca003ddc8fcb67ffe91900c762000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000444b63e800d0000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000075798463024bda64d83c94a64bc7d7eab41300ef00000000000000000000000000000000000000000000000000000000000001400000000000000000000000007579f2ad53b01c3d8779fe17928e0d48885b00030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000babe99e62d8bcbd3acf5ccbcfcd4f64fe75e5e7200000000000000000000000000000000000000000000000000000000000002c447cbbdca0000000000000000000000007579f2ad53b01c3d8779fe17928e0d48885b0003000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000578c4cb0e472a5462da43c495c3f330000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
34
|
+
(0, vitest_1.expect)(salt).toEqual('0xdc83fad4a7d91e2ee81a5adc74eb2bca07d012c5259cb8ea10e89cf05de74c8d');
|
|
35
35
|
(0, vitest_1.expect)(implementation).toEqual('0x29fcb43b46531bca003ddc8fcb67ffe91900c762');
|
|
36
36
|
(0, vitest_1.expect)(initializationCallData).toEqual(null);
|
|
37
37
|
});
|
|
@@ -45,17 +45,17 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
45
45
|
},
|
|
46
46
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
47
47
|
});
|
|
48
|
-
(0, vitest_1.expect)(address).toEqual('
|
|
48
|
+
(0, vitest_1.expect)(address).toEqual('0x3a249204d37245504d4ab37ff88f574b222a6349');
|
|
49
49
|
});
|
|
50
50
|
(0, vitest_1.test)('Passkey owner', () => {
|
|
51
51
|
const address = (0, safe_1.getAddress)({
|
|
52
52
|
owners: {
|
|
53
53
|
type: 'passkey',
|
|
54
|
-
|
|
54
|
+
accounts: [consts_1.passkeyAccount],
|
|
55
55
|
},
|
|
56
56
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
57
57
|
});
|
|
58
|
-
(0, vitest_1.expect)(address).toEqual('
|
|
58
|
+
(0, vitest_1.expect)(address).toEqual('0xe86e416045645e1ca4360d5dc396e4c513277c31');
|
|
59
59
|
});
|
|
60
60
|
});
|
|
61
61
|
(0, vitest_1.describe)('Get Install Data', () => {
|
|
@@ -72,13 +72,12 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
72
72
|
});
|
|
73
73
|
(0, vitest_1.describe)('Get Packed Signature', () => {
|
|
74
74
|
(0, vitest_1.test)('Mock signature', async () => {
|
|
75
|
-
const hash = '0xabcd';
|
|
76
75
|
const mockSignature = '0x1234';
|
|
77
76
|
const validator = {
|
|
78
77
|
address: '0xe35b75e5ec3c04e9cefa8e581fbee859f56edeb4',
|
|
79
78
|
isRoot: true,
|
|
80
79
|
};
|
|
81
|
-
const signature = await (0, safe_1.
|
|
80
|
+
const signature = await (0, safe_1.packSignature)(mockSignature, validator);
|
|
82
81
|
(0, vitest_1.expect)(signature).toEqual('0xe35b75e5ec3c04e9cefa8e581fbee859f56edeb41234');
|
|
83
82
|
});
|
|
84
83
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { WebAuthnP256 } from 'ox';
|
|
2
|
+
import { type Account, type Address, type Chain, type Hex } from 'viem';
|
|
3
|
+
import type { WebAuthnAccount } from 'viem/account-abstraction';
|
|
4
|
+
import type { OwnerSet, SignerSet } from '../../types';
|
|
5
|
+
declare function convertOwnerSetToSignerSet(owners: OwnerSet): SignerSet;
|
|
6
|
+
type SigningFunctions<T> = {
|
|
7
|
+
signEcdsa: (account: Account, params: T) => Promise<Hex>;
|
|
8
|
+
signPasskey: (account: WebAuthnAccount, params: T) => Promise<{
|
|
9
|
+
webauthn: WebAuthnP256.SignMetadata;
|
|
10
|
+
signature: Hex;
|
|
11
|
+
}>;
|
|
12
|
+
};
|
|
13
|
+
declare function signWithMultiFactorAuth<T>(signers: SignerSet & {
|
|
14
|
+
type: 'owner';
|
|
15
|
+
kind: 'multi-factor';
|
|
16
|
+
}, chain: Chain, address: Address, params: T, signMain: (signers: SignerSet, chain: Chain, address: Address, params: T) => Promise<Hex>): Promise<Hex>;
|
|
17
|
+
declare function signWithSession<T>(signers: SignerSet & {
|
|
18
|
+
type: 'session';
|
|
19
|
+
}, chain: Chain, address: Address, params: T, signMain: (signers: SignerSet, chain: Chain, address: Address, params: T) => Promise<Hex>): Promise<Hex>;
|
|
20
|
+
declare function signWithGuardians<T>(signers: SignerSet & {
|
|
21
|
+
type: 'guardians';
|
|
22
|
+
}, params: T, signingFunctions: SigningFunctions<T>): Promise<Hex>;
|
|
23
|
+
declare function signWithOwners<T>(signers: SignerSet & {
|
|
24
|
+
type: 'owner';
|
|
25
|
+
}, chain: Chain, address: Address, params: T, signingFunctions: SigningFunctions<T>, signMain: (signers: SignerSet, chain: Chain, address: Address, params: T) => Promise<Hex>): Promise<Hex>;
|
|
26
|
+
export { convertOwnerSetToSignerSet, signWithMultiFactorAuth, signWithSession, signWithGuardians, signWithOwners, type SigningFunctions, };
|
|
27
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../accounts/signing/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,IAAI,CAAA;AACtC,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,KAAK,EAGV,KAAK,GAAG,EAGT,MAAM,MAAM,CAAA;AACb,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAG/D,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAQtD,iBAAS,0BAA0B,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,CAiD/D;AAED,KAAK,gBAAgB,CAAC,CAAC,IAAI;IACzB,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IACxD,WAAW,EAAE,CACX,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,CAAC,KACN,OAAO,CAAC;QACX,QAAQ,EAAE,YAAY,CAAC,YAAY,CAAA;QACnC,SAAS,EAAE,GAAG,CAAA;KACf,CAAC,CAAA;CACH,CAAA;AAED,iBAAe,uBAAuB,CAAC,CAAC,EACtC,OAAO,EAAE,SAAS,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,cAAc,CAAA;CAAE,EAC5D,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,CAAC,EACT,QAAQ,EAAE,CACR,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,CAAC,KACN,OAAO,CAAC,GAAG,CAAC,GAChB,OAAO,CAAC,GAAG,CAAC,CA0Cd;AAED,iBAAe,eAAe,CAAC,CAAC,EAC9B,OAAO,EAAE,SAAS,GAAG;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,EACxC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,CAAC,EACT,QAAQ,EAAE,CACR,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,CAAC,KACN,OAAO,CAAC,GAAG,CAAC,GAChB,OAAO,CAAC,GAAG,CAAC,CAKd;AAED,iBAAe,iBAAiB,CAAC,CAAC,EAChC,OAAO,EAAE,SAAS,GAAG;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,EAC1C,MAAM,EAAE,CAAC,EACT,gBAAgB,EAAE,gBAAgB,CAAC,CAAC,CAAC,GACpC,OAAO,CAAC,GAAG,CAAC,CAOd;AAED,iBAAe,cAAc,CAAC,CAAC,EAC7B,OAAO,EAAE,SAAS,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,EACtC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,CAAC,EACT,gBAAgB,EAAE,gBAAgB,CAAC,CAAC,CAAC,EACrC,QAAQ,EAAE,CACR,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,CAAC,KACN,OAAO,CAAC,GAAG,CAAC,GAChB,OAAO,CAAC,GAAG,CAAC,CA2Cd;AAED,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,KAAK,gBAAgB,GACtB,CAAA"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertOwnerSetToSignerSet = convertOwnerSetToSignerSet;
|
|
4
|
+
exports.signWithMultiFactorAuth = signWithMultiFactorAuth;
|
|
5
|
+
exports.signWithSession = signWithSession;
|
|
6
|
+
exports.signWithGuardians = signWithGuardians;
|
|
7
|
+
exports.signWithOwners = signWithOwners;
|
|
8
|
+
const viem_1 = require("viem");
|
|
9
|
+
const modules_1 = require("../../modules");
|
|
10
|
+
const core_1 = require("../../modules/validators/core");
|
|
11
|
+
const passkeys_1 = require("./passkeys");
|
|
12
|
+
function convertOwnerSetToSignerSet(owners) {
|
|
13
|
+
switch (owners.type) {
|
|
14
|
+
case 'ecdsa': {
|
|
15
|
+
return {
|
|
16
|
+
type: 'owner',
|
|
17
|
+
kind: 'ecdsa',
|
|
18
|
+
accounts: owners.accounts,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
case 'ecdsa-v0': {
|
|
22
|
+
return {
|
|
23
|
+
type: 'owner',
|
|
24
|
+
kind: 'ecdsa-v0',
|
|
25
|
+
accounts: owners.accounts,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
case 'passkey': {
|
|
29
|
+
return {
|
|
30
|
+
type: 'owner',
|
|
31
|
+
kind: 'passkey',
|
|
32
|
+
accounts: owners.accounts,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
case 'multi-factor': {
|
|
36
|
+
return {
|
|
37
|
+
type: 'owner',
|
|
38
|
+
kind: 'multi-factor',
|
|
39
|
+
validators: owners.validators.map((validator, index) => {
|
|
40
|
+
switch (validator.type) {
|
|
41
|
+
case 'ecdsa':
|
|
42
|
+
case 'ecdsa-v0': {
|
|
43
|
+
return {
|
|
44
|
+
type: validator.type,
|
|
45
|
+
id: index,
|
|
46
|
+
accounts: validator.accounts,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
case 'passkey': {
|
|
50
|
+
return {
|
|
51
|
+
type: 'passkey',
|
|
52
|
+
id: index,
|
|
53
|
+
accounts: validator.accounts,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async function signWithMultiFactorAuth(signers, chain, address, params, signMain) {
|
|
63
|
+
const signatures = await Promise.all(signers.validators.map(async (validator) => {
|
|
64
|
+
if (validator === null) {
|
|
65
|
+
return '0x';
|
|
66
|
+
}
|
|
67
|
+
const validatorSigners = convertOwnerSetToSignerSet(validator);
|
|
68
|
+
return signMain(validatorSigners, chain, address, params);
|
|
69
|
+
}));
|
|
70
|
+
const data = (0, viem_1.encodeAbiParameters)([
|
|
71
|
+
{
|
|
72
|
+
components: [
|
|
73
|
+
{
|
|
74
|
+
internalType: 'bytes32',
|
|
75
|
+
name: 'packedValidatorAndId',
|
|
76
|
+
type: 'bytes32',
|
|
77
|
+
},
|
|
78
|
+
{ internalType: 'bytes', name: 'data', type: 'bytes' },
|
|
79
|
+
],
|
|
80
|
+
name: 'validators',
|
|
81
|
+
type: 'tuple[]',
|
|
82
|
+
},
|
|
83
|
+
], [
|
|
84
|
+
signers.validators.map((validator, index) => {
|
|
85
|
+
const validatorModule = (0, core_1.getValidator)(validator);
|
|
86
|
+
return {
|
|
87
|
+
packedValidatorAndId: (0, viem_1.concat)([
|
|
88
|
+
(0, viem_1.pad)((0, viem_1.toHex)(validator.id), {
|
|
89
|
+
size: 12,
|
|
90
|
+
}),
|
|
91
|
+
validatorModule.address,
|
|
92
|
+
]),
|
|
93
|
+
data: signatures[index],
|
|
94
|
+
};
|
|
95
|
+
}),
|
|
96
|
+
]);
|
|
97
|
+
return data;
|
|
98
|
+
}
|
|
99
|
+
async function signWithSession(signers, chain, address, params, signMain) {
|
|
100
|
+
const sessionSigners = convertOwnerSetToSignerSet(signers.session.owners);
|
|
101
|
+
return signMain(sessionSigners, chain, address, params);
|
|
102
|
+
}
|
|
103
|
+
async function signWithGuardians(signers, params, signingFunctions) {
|
|
104
|
+
const signatures = await Promise.all(signers.guardians.map((account) => signingFunctions.signEcdsa(account, params)));
|
|
105
|
+
return (0, viem_1.concat)(signatures);
|
|
106
|
+
}
|
|
107
|
+
async function signWithOwners(signers, chain, address, params, signingFunctions, signMain) {
|
|
108
|
+
switch (signers.kind) {
|
|
109
|
+
case 'ecdsa':
|
|
110
|
+
case 'ecdsa-v0': {
|
|
111
|
+
const signatures = await Promise.all(signers.accounts.map((account) => signingFunctions.signEcdsa(account, params)));
|
|
112
|
+
return (0, viem_1.concat)(signatures);
|
|
113
|
+
}
|
|
114
|
+
case 'passkey': {
|
|
115
|
+
const signatures = await Promise.all(signers.accounts.map((account) => signingFunctions.signPasskey(account, params)));
|
|
116
|
+
const usePrecompile = (0, modules_1.isRip7212SupportedNetwork)(chain);
|
|
117
|
+
const credIds = signers.accounts.map((account) => {
|
|
118
|
+
const publicKey = account.publicKey;
|
|
119
|
+
const { x, y } = (0, passkeys_1.parsePublicKey)(publicKey);
|
|
120
|
+
return (0, passkeys_1.generateCredentialId)(x, y, address);
|
|
121
|
+
});
|
|
122
|
+
const webAuthns = signatures.map((signature) => {
|
|
123
|
+
const { r, s } = (0, passkeys_1.parseSignature)(signature.signature);
|
|
124
|
+
return {
|
|
125
|
+
authenticatorData: signature.webauthn.authenticatorData,
|
|
126
|
+
clientDataJSON: signature.webauthn.clientDataJSON,
|
|
127
|
+
challengeIndex: BigInt(signature.webauthn.challengeIndex),
|
|
128
|
+
typeIndex: BigInt(signature.webauthn.typeIndex),
|
|
129
|
+
r,
|
|
130
|
+
s,
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
return (0, passkeys_1.packSignature)(credIds, usePrecompile, webAuthns);
|
|
134
|
+
}
|
|
135
|
+
case 'multi-factor': {
|
|
136
|
+
return signWithMultiFactorAuth(signers, chain, address, params, signMain);
|
|
137
|
+
}
|
|
138
|
+
default: {
|
|
139
|
+
throw new Error('Unsupported owner kind');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../../accounts/signing/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,KAAK,EAEV,KAAK,GAAG,EAGT,MAAM,MAAM,CAAA;AAEb,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAS5C,iBAAe,IAAI,CACjB,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,GAAG,GACR,OAAO,CAAC,GAAG,CAAC,CAwBd;AA4BD,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sign = sign;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const error_1 = require("../error");
|
|
6
|
+
const common_1 = require("./common");
|
|
7
|
+
async function sign(signers, chain, address, hash) {
|
|
8
|
+
const signingFunctions = {
|
|
9
|
+
signEcdsa: (account, hash) => signEcdsa(account, hash),
|
|
10
|
+
signPasskey: (account, hash) => signPasskey(account, hash),
|
|
11
|
+
};
|
|
12
|
+
switch (signers.type) {
|
|
13
|
+
case 'owner': {
|
|
14
|
+
return (0, common_1.signWithOwners)(signers, chain, address, hash, signingFunctions, sign);
|
|
15
|
+
}
|
|
16
|
+
case 'session': {
|
|
17
|
+
return (0, common_1.signWithSession)(signers, chain, address, hash, sign);
|
|
18
|
+
}
|
|
19
|
+
case 'guardians': {
|
|
20
|
+
return (0, common_1.signWithGuardians)(signers, hash, signingFunctions);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async function signEcdsa(account, hash) {
|
|
25
|
+
if (!account.signMessage) {
|
|
26
|
+
throw new error_1.SigningNotSupportedForAccountError();
|
|
27
|
+
}
|
|
28
|
+
const originalSignature = await account.signMessage({
|
|
29
|
+
message: { raw: hash },
|
|
30
|
+
});
|
|
31
|
+
// Manually tweak the `v` value to trigger the message prefixing onchain
|
|
32
|
+
// https://github.com/rhinestonewtf/checknsignatures/blob/main/src/CheckNSignatures.sol#L53-L61
|
|
33
|
+
const { r, s, v } = (0, viem_1.parseSignature)(originalSignature);
|
|
34
|
+
if (!v) {
|
|
35
|
+
throw new Error('Invalid signature');
|
|
36
|
+
}
|
|
37
|
+
const newV = v + 4n;
|
|
38
|
+
const newSignature = (0, viem_1.concat)([r, s, (0, viem_1.toHex)(newV)]);
|
|
39
|
+
return newSignature;
|
|
40
|
+
}
|
|
41
|
+
async function signPasskey(account, hash) {
|
|
42
|
+
const { webauthn, signature } = await account.sign({ hash });
|
|
43
|
+
return {
|
|
44
|
+
webauthn,
|
|
45
|
+
signature,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Address, type Hex } from 'viem';
|
|
2
|
+
interface WebAuthnSignature {
|
|
3
|
+
authenticatorData: Hex;
|
|
4
|
+
clientDataJSON: string;
|
|
5
|
+
challengeIndex: bigint;
|
|
6
|
+
typeIndex: bigint;
|
|
7
|
+
r: bigint;
|
|
8
|
+
s: bigint;
|
|
9
|
+
}
|
|
10
|
+
declare function parsePublicKey(publicKey: Hex | Uint8Array): {
|
|
11
|
+
x: bigint;
|
|
12
|
+
y: bigint;
|
|
13
|
+
};
|
|
14
|
+
declare function parseSignature(signature: Hex | Uint8Array): {
|
|
15
|
+
r: bigint;
|
|
16
|
+
s: bigint;
|
|
17
|
+
};
|
|
18
|
+
declare function generateCredentialId(pubKeyX: bigint, pubKeyY: bigint, account: Address): `0x${string}`;
|
|
19
|
+
declare function packSignature(credIds: Hex[], usePrecompile: boolean, webAuthns: {
|
|
20
|
+
authenticatorData: Hex;
|
|
21
|
+
clientDataJSON: string;
|
|
22
|
+
challengeIndex: bigint;
|
|
23
|
+
typeIndex: bigint;
|
|
24
|
+
r: bigint;
|
|
25
|
+
s: bigint;
|
|
26
|
+
}[]): Hex;
|
|
27
|
+
export { parsePublicKey, parseSignature, generateCredentialId, packSignature };
|
|
28
|
+
export type { WebAuthnSignature };
|
|
29
|
+
//# sourceMappingURL=passkeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passkeys.d.ts","sourceRoot":"","sources":["../../../../accounts/signing/passkeys.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EAGZ,KAAK,GAAG,EAGT,MAAM,MAAM,CAAA;AAEb,UAAU,iBAAiB;IACzB,iBAAiB,EAAE,GAAG,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED,iBAAS,cAAc,CAAC,SAAS,EAAE,GAAG,GAAG,UAAU,GAAG;IACpD,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV,CAUA;AAED,iBAAS,cAAc,CAAC,SAAS,EAAE,GAAG,GAAG,UAAU,GAAG;IACpD,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV,CASA;AAED,iBAAS,oBAAoB,CAC3B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,OAAO,iBAkBjB;AAED,iBAAS,aAAa,CACpB,OAAO,EAAE,GAAG,EAAE,EACd,aAAa,EAAE,OAAO,EACtB,SAAS,EAAE;IACT,iBAAiB,EAAE,GAAG,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV,EAAE,GACF,GAAG,CAqDL;AAED,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,oBAAoB,EAAE,aAAa,EAAE,CAAA;AAC9E,YAAY,EAAE,iBAAiB,EAAE,CAAA"}
|