@charterlabs/rhinestone-sdk 0.2.7-dev.3 → 0.2.8
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 +46 -8
- package/dist/src/accounts/error.d.ts +38 -3
- package/dist/src/accounts/error.d.ts.map +1 -1
- package/dist/src/accounts/error.js +55 -7
- package/dist/src/accounts/index.d.ts +31 -20
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +231 -25
- package/dist/src/accounts/index.test.js +2 -4
- 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/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 +52 -0
- package/dist/src/accounts/kernel.d.ts +1 -1
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +29 -1
- package/dist/src/accounts/kernel.test.js +35 -8
- package/dist/src/accounts/nexus.d.ts +4 -3
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +82 -14
- package/dist/src/accounts/nexus.test.js +33 -6
- package/dist/src/accounts/passport.d.ts +12 -0
- package/dist/src/accounts/passport.d.ts.map +1 -0
- package/dist/src/accounts/passport.js +173 -0
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +85 -53
- package/dist/src/accounts/safe.test.js +33 -6
- package/dist/src/accounts/signing/common.d.ts +4 -4
- package/dist/src/accounts/signing/common.d.ts.map +1 -1
- package/dist/src/accounts/signing/common.js +21 -9
- package/dist/src/accounts/signing/message.d.ts +1 -1
- package/dist/src/accounts/signing/message.d.ts.map +1 -1
- package/dist/src/accounts/signing/message.js +6 -6
- package/dist/src/accounts/signing/passkeys.d.ts +8 -1
- package/dist/src/accounts/signing/passkeys.d.ts.map +1 -1
- package/dist/src/accounts/signing/passkeys.js +35 -0
- package/dist/src/accounts/signing/passkeys.test.js +15 -0
- package/dist/src/accounts/signing/typedData.d.ts.map +1 -1
- package/dist/src/accounts/signing/typedData.js +2 -2
- package/dist/src/accounts/startale.test.js +0 -4
- package/dist/src/accounts/utils.d.ts +4 -4
- package/dist/src/accounts/utils.d.ts.map +1 -1
- package/dist/src/accounts/utils.js +3 -40
- package/dist/src/accounts/walletClient.d.ts +7 -0
- package/dist/src/accounts/walletClient.d.ts.map +1 -0
- package/dist/src/accounts/walletClient.js +38 -0
- package/dist/src/actions/compact.d.ts +13 -0
- package/dist/src/actions/compact.d.ts.map +1 -0
- package/dist/src/actions/compact.js +210 -0
- package/dist/src/actions/ecdsa.d.ts +35 -0
- package/dist/src/actions/ecdsa.d.ts.map +1 -0
- package/dist/src/actions/ecdsa.js +114 -0
- package/dist/src/actions/ecdsa.test.d.ts +2 -0
- package/dist/src/actions/ecdsa.test.d.ts.map +1 -0
- package/dist/src/actions/ecdsa.test.js +99 -0
- package/dist/src/actions/index.d.ts +23 -166
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +25 -544
- package/dist/src/actions/mfa.d.ts +37 -0
- package/dist/src/actions/mfa.d.ts.map +1 -0
- package/dist/src/actions/mfa.js +133 -0
- package/dist/src/actions/passkeys.d.ts +37 -0
- package/dist/src/actions/passkeys.d.ts.map +1 -0
- package/dist/src/actions/passkeys.js +129 -0
- package/dist/src/actions/passkeys.test.d.ts +2 -0
- package/dist/src/actions/passkeys.test.d.ts.map +1 -0
- package/dist/src/actions/passkeys.test.js +54 -0
- package/dist/src/actions/recovery.d.ts +33 -0
- package/dist/src/actions/recovery.d.ts.map +1 -0
- package/dist/src/actions/recovery.js +193 -0
- package/dist/src/actions/recovery.test.d.ts +2 -0
- package/dist/src/actions/recovery.test.d.ts.map +1 -0
- package/dist/src/actions/recovery.test.js +168 -0
- package/dist/src/actions/smart-sessions.d.ts +23 -0
- package/dist/src/actions/smart-sessions.d.ts.map +1 -0
- package/dist/src/actions/{smart-session.js → smart-sessions.js} +13 -0
- package/dist/src/errors/index.d.ts +5 -0
- package/dist/src/errors/index.d.ts.map +1 -0
- package/dist/src/errors/index.js +50 -0
- package/dist/src/execution/compact.d.ts +25 -9
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +29 -103
- package/dist/src/execution/error.d.ts +6 -6
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +13 -13
- package/dist/src/execution/index.d.ts +34 -22
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +115 -46
- package/dist/src/execution/multiChainOps.d.ts +40 -0
- package/dist/src/execution/multiChainOps.d.ts.map +1 -0
- package/dist/src/execution/multiChainOps.js +39 -0
- package/dist/src/execution/permit2.d.ts +148 -0
- package/dist/src/execution/permit2.d.ts.map +1 -0
- package/dist/src/execution/permit2.js +291 -0
- package/dist/src/execution/smart-session.d.ts +3 -3
- package/dist/src/execution/smart-session.d.ts.map +1 -1
- package/dist/src/execution/smart-session.js +3 -3
- package/dist/src/execution/types.d.ts +36 -0
- package/dist/src/execution/types.d.ts.map +1 -0
- package/dist/src/execution/types.js +2 -0
- package/dist/src/execution/utils.d.ts +43 -28
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +269 -99
- package/dist/src/index.d.ts +38 -19
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +121 -69
- package/dist/src/modules/common.d.ts +10 -4
- package/dist/src/modules/common.d.ts.map +1 -1
- package/dist/src/modules/common.js +22 -1
- package/dist/src/modules/index.d.ts +3 -2
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +16 -13
- package/dist/src/modules/index.test.js +9 -12
- package/dist/src/modules/read.d.ts.map +1 -1
- package/dist/src/modules/read.js +5 -1
- package/dist/src/modules/validators/core.d.ts +5 -3
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +29 -10
- package/dist/src/modules/validators/core.test.js +4 -4
- package/dist/src/modules/validators/smart-sessions.d.ts +4 -4
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
- package/dist/src/modules/validators/smart-sessions.js +10 -72
- package/dist/src/modules/validators/smart-sessions.test.js +4 -8
- package/dist/src/modules/validators/webauthn-contract.d.ts.map +1 -1
- package/dist/src/orchestrator/client.d.ts +4 -2
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +230 -162
- package/dist/src/orchestrator/consts.d.ts +1 -2
- package/dist/src/orchestrator/consts.d.ts.map +1 -1
- package/dist/src/orchestrator/consts.js +1 -3
- package/dist/src/orchestrator/error.d.ts +111 -1
- package/dist/src/orchestrator/error.d.ts.map +1 -1
- package/dist/src/orchestrator/error.js +128 -1
- package/dist/src/orchestrator/index.d.ts +4 -4
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +16 -1
- package/dist/src/orchestrator/registry.d.ts +3 -25
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +82 -46
- package/dist/src/orchestrator/registry.test.js +7 -7
- package/dist/src/orchestrator/types.d.ts +53 -43
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/types.d.ts +74 -9
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/index.d.ts +3 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/utils/index.js +5 -0
- package/package.json +73 -2
- package/dist/src/actions/index.test.d.ts +0 -2
- package/dist/src/actions/index.test.d.ts.map +0 -1
- package/dist/src/actions/index.test.js +0 -302
- package/dist/src/actions/smart-session.d.ts +0 -11
- package/dist/src/actions/smart-session.d.ts.map +0 -1
- package/dist/src/orchestrator/registry.json +0 -365
|
@@ -13,13 +13,12 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
13
13
|
type: 'ecdsa',
|
|
14
14
|
accounts: [consts_1.accountA, consts_1.accountB],
|
|
15
15
|
},
|
|
16
|
-
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
17
16
|
});
|
|
18
17
|
(0, vitest_1.expect)(factory).toEqual('0xd703aae79538628d27099b8c4f621be4ccd142d5');
|
|
19
|
-
(0, vitest_1.expect)(factoryData).toEqual('
|
|
18
|
+
(0, vitest_1.expect)(factoryData).toEqual('0xc5265d5d0000000000000000000000002577507b78c2008ff367261cb6285d44ba5ef2e90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003243c3b752b01000000000013fdb5234e4e3162a810f54d9f7e980000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000094000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
20
19
|
(0, vitest_1.expect)(salt).toEqual('0x0000000000000000000000000000000000000000000000000000000000000000');
|
|
21
20
|
(0, vitest_1.expect)(implementation).toEqual('0xd6CEDDe84be40893d153Be9d467CD6aD37875b28');
|
|
22
|
-
(0, vitest_1.expect)(initializationCallData).toEqual('
|
|
21
|
+
(0, vitest_1.expect)(initializationCallData).toEqual('0x3c3b752b01000000000013fdb5234e4e3162a810f54d9f7e980000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
23
22
|
});
|
|
24
23
|
(0, vitest_1.test)('Passkey owner', () => {
|
|
25
24
|
const { factory, factoryData, salt, implementation, initializationCallData, } = (0, kernel_1.getDeployArgs)({
|
|
@@ -27,13 +26,28 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
27
26
|
type: 'passkey',
|
|
28
27
|
accounts: [consts_1.passkeyAccount],
|
|
29
28
|
},
|
|
30
|
-
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
31
29
|
});
|
|
32
30
|
(0, vitest_1.expect)(factory).toEqual('0xd703aae79538628d27099b8c4f621be4ccd142d5');
|
|
33
|
-
(0, vitest_1.expect)(factoryData).toEqual('
|
|
31
|
+
(0, vitest_1.expect)(factoryData).toEqual('0xc5265d5d0000000000000000000000002577507b78c2008ff367261cb6285d44ba5ef2e90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003443c3b752b010000000000578c4cb0e472a5462da43c495c3f330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000094000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
34
32
|
(0, vitest_1.expect)(salt).toEqual('0x0000000000000000000000000000000000000000000000000000000000000000');
|
|
35
33
|
(0, vitest_1.expect)(implementation).toEqual('0xd6CEDDe84be40893d153Be9d467CD6aD37875b28');
|
|
36
|
-
(0, vitest_1.expect)(initializationCallData).toEqual('
|
|
34
|
+
(0, vitest_1.expect)(initializationCallData).toEqual('0x3c3b752b010000000000578c4cb0e472a5462da43c495c3f330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
35
|
+
});
|
|
36
|
+
(0, vitest_1.test)('Existing account', () => {
|
|
37
|
+
const { factory, factoryData } = (0, kernel_1.getDeployArgs)({
|
|
38
|
+
owners: {
|
|
39
|
+
type: 'ecdsa',
|
|
40
|
+
accounts: [consts_1.accountA, consts_1.accountB],
|
|
41
|
+
},
|
|
42
|
+
initData: {
|
|
43
|
+
address: '0x86c4b9c9eA5df80D4e080e285015Cda47A503B51',
|
|
44
|
+
factory: '0xd703aaE79538628d27099B8c4f621bE4CCd142d5',
|
|
45
|
+
factoryData: '0xc5265d5d0000000000000000000000002577507b78c2008ff367261cb6285d44ba5ef2e90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001243c3b752b01845ADb2C711129d4f3966735eD98a9F09fC4cE570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001460098F8D98a9c55F21D17C26c78bF3D71Edc0E740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
|
46
|
+
intentExecutorInstalled: false,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
(0, vitest_1.expect)(factory).toEqual('0xd703aaE79538628d27099B8c4f621bE4CCd142d5');
|
|
50
|
+
(0, vitest_1.expect)(factoryData).toEqual('0xc5265d5d0000000000000000000000002577507b78c2008ff367261cb6285d44ba5ef2e90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001243c3b752b01845ADb2C711129d4f3966735eD98a9F09fC4cE570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001460098F8D98a9c55F21D17C26c78bF3D71Edc0E740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
37
51
|
});
|
|
38
52
|
});
|
|
39
53
|
(0, vitest_1.describe)('Get Address', () => {
|
|
@@ -43,7 +57,6 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
43
57
|
type: 'ecdsa',
|
|
44
58
|
accounts: [consts_1.accountA, consts_1.accountB],
|
|
45
59
|
},
|
|
46
|
-
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
47
60
|
});
|
|
48
61
|
(0, vitest_1.expect)(address).toEqual('0xC3733a544f5246a25405c7446e4D0C6b5762B22e');
|
|
49
62
|
});
|
|
@@ -53,10 +66,24 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
53
66
|
type: 'passkey',
|
|
54
67
|
accounts: [consts_1.passkeyAccount],
|
|
55
68
|
},
|
|
56
|
-
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
57
69
|
});
|
|
58
70
|
(0, vitest_1.expect)(address).toEqual('0xE48268B1C69528366d8eFaC5DB6fA947a7B52E55');
|
|
59
71
|
});
|
|
72
|
+
(0, vitest_1.test)('Existing account', () => {
|
|
73
|
+
const address = (0, kernel_1.getAddress)({
|
|
74
|
+
owners: {
|
|
75
|
+
type: 'ecdsa',
|
|
76
|
+
accounts: [consts_1.accountA, consts_1.accountB],
|
|
77
|
+
},
|
|
78
|
+
initData: {
|
|
79
|
+
address: '0x86c4b9c9eA5df80D4e080e285015Cda47A503B51',
|
|
80
|
+
factory: '0xd703aaE79538628d27099B8c4f621bE4CCd142d5',
|
|
81
|
+
factoryData: '0xc5265d5d0000000000000000000000002577507b78c2008ff367261cb6285d44ba5ef2e90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001243c3b752b01845ADb2C711129d4f3966735eD98a9F09fC4cE570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001460098F8D98a9c55F21D17C26c78bF3D71Edc0E740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
|
82
|
+
intentExecutorInstalled: false,
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
(0, vitest_1.expect)(address).toEqual('0x86c4b9c9eA5df80D4e080e285015Cda47A503B51');
|
|
86
|
+
});
|
|
60
87
|
});
|
|
61
88
|
(0, vitest_1.describe)('Get Install Data', () => {
|
|
62
89
|
(0, vitest_1.test)('Module', () => {
|
|
@@ -5,15 +5,16 @@ import type { EnableSessionData } from '../modules/validators/smart-sessions';
|
|
|
5
5
|
import type { OwnerSet, RhinestoneAccountConfig, Session } from '../types';
|
|
6
6
|
import { type ValidatorConfig } from './utils';
|
|
7
7
|
declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
8
|
+
salt: `0x${string}`;
|
|
8
9
|
factory: `0x${string}`;
|
|
9
10
|
factoryData: `0x${string}`;
|
|
10
|
-
salt: `0x${string}`;
|
|
11
11
|
implementation: `0x${string}`;
|
|
12
|
-
initializationCallData: `0x${string}`;
|
|
13
12
|
initData: `0x${string}`;
|
|
13
|
+
initializationCallData: `0x${string}`;
|
|
14
14
|
};
|
|
15
15
|
declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
|
|
16
16
|
declare function getInstallData(module: Module): `0x${string}`;
|
|
17
|
+
declare function getDefaultValidatorAddress(version: '1.0.2' | '1.2.0' | 'rhinestone-1.0.0-beta' | 'rhinestone-1.0.0' | undefined): Address;
|
|
17
18
|
declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex, defaultValidatorAddress?: Address): Promise<`0x${string}`>;
|
|
18
19
|
declare function getSmartAccount(client: PublicClient, address: Address, owners: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>, defaultValidatorAddress?: Address): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
19
20
|
declare function getSessionSmartAccount(client: PublicClient, address: Address, session: Session, validatorAddress: Address, enableData: EnableSessionData | null, sign: (hash: Hex) => Promise<Hex>, defaultValidatorAddress?: Address): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
@@ -23,5 +24,5 @@ declare function getEip7702InitCall(config: RhinestoneAccountConfig, signature:
|
|
|
23
24
|
initData: `0x${string}`;
|
|
24
25
|
contract: `0x${string}`;
|
|
25
26
|
}>;
|
|
26
|
-
export { getInstallData, getAddress, packSignature, getDeployArgs, getSmartAccount, getSessionSmartAccount, getGuardianSmartAccount, signEip7702InitData, getEip7702InitCall, };
|
|
27
|
+
export { getInstallData, getAddress, getDefaultValidatorAddress, packSignature, getDeployArgs, getSmartAccount, getSessionSmartAccount, getGuardianSmartAccount, signEip7702InitData, getEip7702InitCall, };
|
|
27
28
|
//# sourceMappingURL=nexus.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nexus.d.ts","sourceRoot":"","sources":["../../../accounts/nexus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"nexus.d.ts","sourceRoot":"","sources":["../../../accounts/nexus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAcpE,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAEhC,MAAM,0BAA0B,CAAA;AAGjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAS/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAC7E,OAAO,KAAK,EAAE,QAAQ,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAK1E,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAoBhF,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;;EAoJrD;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,iBAgClD;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE,MAAM,iBA2BrC;AAED,iBAAS,0BAA0B,CACjC,OAAO,EACH,OAAO,GACP,OAAO,GACP,uBAAuB,GACvB,kBAAkB,GAClB,SAAS,GACZ,OAAO,CAcT;AAED,iBAAe,aAAa,CAC1B,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,eAAe,EAC1B,kBAAkB,GAAE,CAAC,SAAS,EAAE,GAAG,KAAK,GAA8B,EACtE,uBAAuB,GAAE,OAAyC,0BAWnE;AAED,iBAAe,eAAe,CAC5B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,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,0BAA0B,EAC1B,aAAa,EACb,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,GACnB,CAAA"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getInstallData = getInstallData;
|
|
4
4
|
exports.getAddress = getAddress;
|
|
5
|
+
exports.getDefaultValidatorAddress = getDefaultValidatorAddress;
|
|
5
6
|
exports.packSignature = packSignature;
|
|
6
7
|
exports.getDeployArgs = getDeployArgs;
|
|
7
8
|
exports.getSmartAccount = getSmartAccount;
|
|
@@ -20,8 +21,52 @@ const NEXUS_DEFAULT_VALIDATOR_ADDRESS = core_1.OWNABLE_VALIDATOR_ADDRESS;
|
|
|
20
21
|
const NEXUS_IMPLEMENTATION_ADDRESS = '0x000000000032dDC454C3BDcba80484Ad5A798705';
|
|
21
22
|
const NEXUS_FACTORY_ADDRESS = '0x0000000000679A258c64d2F20F310e12B64b7375';
|
|
22
23
|
const NEXUS_BOOTSTRAP_ADDRESS = '0x00000000006eFb61D8c9546FF1B500de3f244EA7';
|
|
24
|
+
const NEXUS_IMPLEMENTATION_1_0_0 = '0x000000039dfcad030719b07296710f045f0558f7';
|
|
25
|
+
const NEXUS_BOOTSTRAP_1_0_0 = '0x00000008c901d8871b6f6942de0b5d9ccf3873d3';
|
|
26
|
+
const NEXUS_K1_VALIDATOR = '0x00000004171351c442b202678c48d8ab5b321e8f';
|
|
23
27
|
const NEXUS_CREATION_CODE = '0x60806040526102aa803803806100148161018c565b92833981016040828203126101885781516001600160a01b03811692909190838303610188576020810151906001600160401b03821161018857019281601f8501121561018857835161006e610069826101c5565b61018c565b9481865260208601936020838301011161018857815f926020809301865e8601015260017f90b772c2cb8a51aa7a8a65fc23543c6d022d5b3f8e2b92eed79fba7eef8293005d823b15610176577f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b031916821790557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b5f80a282511561015e575f8091610146945190845af43d15610156573d91610137610069846101c5565b9283523d5f602085013e6101e0565b505b604051606b908161023f8239f35b6060916101e0565b50505034156101485763b398979f60e01b5f5260045ffd5b634c9c8ce360e01b5f5260045260245ffd5b5f80fd5b6040519190601f01601f191682016001600160401b038111838210176101b157604052565b634e487b7160e01b5f52604160045260245ffd5b6001600160401b0381116101b157601f01601f191660200190565b9061020457508051156101f557805190602001fd5b63d6bda27560e01b5f5260045ffd5b81511580610235575b610215575090565b639996b31560e01b5f9081526001600160a01b0391909116600452602490fd5b50803b1561020d56fe60806040523615605c575f8073ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416368280378136915af43d5f803e156058573d5ff35b3d5ffd5b00fea164736f6c634300081b000a';
|
|
24
28
|
function getDeployArgs(config) {
|
|
29
|
+
if (config.initData) {
|
|
30
|
+
const factoryData = (0, viem_1.decodeFunctionData)({
|
|
31
|
+
abi: (0, viem_1.parseAbi)([
|
|
32
|
+
'function createAccount(address eoaOwner,uint256 index,address[] attesters,uint8 threshold)',
|
|
33
|
+
]),
|
|
34
|
+
data: config.initData.factoryData,
|
|
35
|
+
});
|
|
36
|
+
if (factoryData.functionName !== 'createAccount') {
|
|
37
|
+
throw new error_1.AccountConfigurationNotSupportedError('Invalid factory data', 'nexus');
|
|
38
|
+
}
|
|
39
|
+
const owner = factoryData.args[0];
|
|
40
|
+
const index = factoryData.args[1];
|
|
41
|
+
const attesters = factoryData.args[2];
|
|
42
|
+
const threshold = factoryData.args[3];
|
|
43
|
+
const salt = (0, viem_1.keccak256)((0, viem_1.encodePacked)(['address', 'uint256', 'address[]', 'uint8'], [owner, index, attesters, threshold]));
|
|
44
|
+
const implementation = config.initData.factory === NEXUS_FACTORY_ADDRESS
|
|
45
|
+
? NEXUS_IMPLEMENTATION_ADDRESS
|
|
46
|
+
: NEXUS_IMPLEMENTATION_1_0_0;
|
|
47
|
+
const registry = viem_1.zeroAddress;
|
|
48
|
+
const bootstrapData = (0, viem_1.encodeFunctionData)({
|
|
49
|
+
abi: (0, viem_1.parseAbi)([
|
|
50
|
+
'function initNexusWithSingleValidator(address validator,bytes data,address registry,address[] attesters,uint8 threshold)',
|
|
51
|
+
]),
|
|
52
|
+
functionName: 'initNexusWithSingleValidator',
|
|
53
|
+
args: [NEXUS_K1_VALIDATOR, owner, registry, attesters, threshold],
|
|
54
|
+
});
|
|
55
|
+
const initData = (0, viem_1.encodeAbiParameters)([{ type: 'address' }, { type: 'bytes' }], [NEXUS_BOOTSTRAP_1_0_0, bootstrapData]);
|
|
56
|
+
const initializationCallData = (0, viem_1.encodeFunctionData)({
|
|
57
|
+
abi: (0, viem_1.parseAbi)(['function initializeAccount(bytes)']),
|
|
58
|
+
functionName: 'initializeAccount',
|
|
59
|
+
args: [initData],
|
|
60
|
+
});
|
|
61
|
+
return {
|
|
62
|
+
salt,
|
|
63
|
+
factory: config.initData.factory,
|
|
64
|
+
factoryData: config.initData.factoryData,
|
|
65
|
+
implementation,
|
|
66
|
+
initData,
|
|
67
|
+
initializationCallData,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
25
70
|
const salt = (0, viem_1.keccak256)('0x');
|
|
26
71
|
const moduleSetup = (0, modules_1.getSetup)(config);
|
|
27
72
|
// Filter out the default validator
|
|
@@ -107,20 +152,28 @@ function getDeployArgs(config) {
|
|
|
107
152
|
};
|
|
108
153
|
}
|
|
109
154
|
function getAddress(config) {
|
|
110
|
-
const { factory, salt, initializationCallData } = getDeployArgs(config);
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
155
|
+
const { factory, salt, initializationCallData, implementation } = getDeployArgs(config);
|
|
156
|
+
const creationCode = factory === NEXUS_FACTORY_ADDRESS
|
|
157
|
+
? NEXUS_CREATION_CODE
|
|
158
|
+
: '0x603d3d8160223d3973000000039dfcad030719b07296710f045f0558f760095155f3363d3d373d3d363d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc545af43d6000803e6038573d6000fd5b3d6000f3';
|
|
159
|
+
const accountInitData = factory === NEXUS_FACTORY_ADDRESS
|
|
160
|
+
? (0, viem_1.encodeAbiParameters)([
|
|
161
|
+
{
|
|
162
|
+
name: 'address',
|
|
163
|
+
type: 'address',
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: 'calldata',
|
|
167
|
+
type: 'bytes',
|
|
168
|
+
},
|
|
169
|
+
], [implementation, initializationCallData])
|
|
170
|
+
: '0x';
|
|
171
|
+
const address = (0, viem_1.getContractAddress)({
|
|
172
|
+
opcode: 'CREATE2',
|
|
173
|
+
from: factory,
|
|
174
|
+
salt,
|
|
175
|
+
bytecode: (0, viem_1.concat)([creationCode, accountInitData]),
|
|
176
|
+
});
|
|
124
177
|
return address;
|
|
125
178
|
}
|
|
126
179
|
function getInstallData(module) {
|
|
@@ -151,6 +204,21 @@ function getInstallData(module) {
|
|
|
151
204
|
args: [module.type, module.address, module.initData],
|
|
152
205
|
});
|
|
153
206
|
}
|
|
207
|
+
function getDefaultValidatorAddress(version) {
|
|
208
|
+
if (!version) {
|
|
209
|
+
return NEXUS_DEFAULT_VALIDATOR_ADDRESS;
|
|
210
|
+
}
|
|
211
|
+
switch (version) {
|
|
212
|
+
case '1.0.2':
|
|
213
|
+
return '0x0000002D6DB27c52E3C11c1Cf24072004AC75cBa';
|
|
214
|
+
case '1.2.0':
|
|
215
|
+
return '0x00000000d12897ddadc2044614a9677b191a2d95';
|
|
216
|
+
case 'rhinestone-1.0.0-beta':
|
|
217
|
+
return '0x0000000000e9e6e96bcaa3c113187cdb7e38aed9';
|
|
218
|
+
case 'rhinestone-1.0.0':
|
|
219
|
+
return NEXUS_DEFAULT_VALIDATOR_ADDRESS;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
154
222
|
async function packSignature(signature, validator, transformSignature = (signature) => signature, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
|
|
155
223
|
const validatorAddress = validator.address === defaultValidatorAddress
|
|
156
224
|
? viem_1.zeroAddress
|
|
@@ -13,7 +13,6 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
13
13
|
type: 'ecdsa',
|
|
14
14
|
accounts: [consts_1.accountA, consts_1.accountB],
|
|
15
15
|
},
|
|
16
|
-
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
17
16
|
});
|
|
18
17
|
(0, vitest_1.expect)(factory).toEqual('0x0000000000679A258c64d2F20F310e12B64b7375');
|
|
19
18
|
(0, vitest_1.expect)(factoryData).toEqual('0xea6d13ac0000000000000000000000000000000000000000000000000000000000000040c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470000000000000000000000000000000000000000000000000000000000000036000000000000000000000000000000000006efb61d8c9546ff1b500de3f244ea7000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000002e441bede0300000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
@@ -27,7 +26,6 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
27
26
|
type: 'passkey',
|
|
28
27
|
accounts: [consts_1.passkeyAccount],
|
|
29
28
|
},
|
|
30
|
-
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
31
29
|
});
|
|
32
30
|
(0, vitest_1.expect)(factory).toEqual('0x0000000000679A258c64d2F20F310e12B64b7375');
|
|
33
31
|
(0, vitest_1.expect)(factoryData).toEqual('0xea6d13ac0000000000000000000000000000000000000000000000000000000000000040c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000006efb61d8c9546ff1b500de3f244ea7000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000003448643787600000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000578c4cb0e472a5462da43c495c3f33000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
@@ -35,6 +33,22 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
35
33
|
(0, vitest_1.expect)(implementation).toEqual('0x000000000032dDC454C3BDcba80484Ad5A798705');
|
|
36
34
|
(0, vitest_1.expect)(initializationCallData).toEqual('0x4b6a1419000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000006efb61d8c9546ff1b500de3f244ea7000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000003448643787600000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000578c4cb0e472a5462da43c495c3f33000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
37
35
|
});
|
|
36
|
+
(0, vitest_1.test)('Existing account', () => {
|
|
37
|
+
const { factory, factoryData } = (0, nexus_1.getDeployArgs)({
|
|
38
|
+
owners: {
|
|
39
|
+
type: 'ecdsa',
|
|
40
|
+
accounts: [consts_1.accountA, consts_1.accountB],
|
|
41
|
+
},
|
|
42
|
+
initData: {
|
|
43
|
+
address: '0xBecba00993a919FfD35064a777E94643014A19Aa',
|
|
44
|
+
factory: '0x00000bb19a3579F4D779215dEf97AFbd0e30DB55',
|
|
45
|
+
factoryData: '0x0d51f0b7000000000000000000000000db8fca317427c3f85b6734af6455f287011c54b50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
|
46
|
+
intentExecutorInstalled: false,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
(0, vitest_1.expect)(factory).toEqual('0x00000bb19a3579F4D779215dEf97AFbd0e30DB55');
|
|
50
|
+
(0, vitest_1.expect)(factoryData).toEqual('0x0d51f0b7000000000000000000000000db8fca317427c3f85b6734af6455f287011c54b50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
51
|
+
});
|
|
38
52
|
});
|
|
39
53
|
(0, vitest_1.describe)('Get Address', () => {
|
|
40
54
|
(0, vitest_1.test)('ECDSA owners', () => {
|
|
@@ -43,9 +57,8 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
43
57
|
type: 'ecdsa',
|
|
44
58
|
accounts: [consts_1.accountA, consts_1.accountB],
|
|
45
59
|
},
|
|
46
|
-
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
47
60
|
});
|
|
48
|
-
(0, vitest_1.expect)(address).toEqual('
|
|
61
|
+
(0, vitest_1.expect)(address).toEqual('0x0681de31e060b384F0b08A3bAC99E9bDFf302474');
|
|
49
62
|
});
|
|
50
63
|
(0, vitest_1.test)('Passkey owner', () => {
|
|
51
64
|
const address = (0, nexus_1.getAddress)({
|
|
@@ -53,9 +66,23 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
53
66
|
type: 'passkey',
|
|
54
67
|
accounts: [consts_1.passkeyAccount],
|
|
55
68
|
},
|
|
56
|
-
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
57
69
|
});
|
|
58
|
-
(0, vitest_1.expect)(address).toEqual('
|
|
70
|
+
(0, vitest_1.expect)(address).toEqual('0x894b88C04B4DE6AbDdcE81E8bdc91927E37d6ceD');
|
|
71
|
+
});
|
|
72
|
+
(0, vitest_1.test)('Existing account', () => {
|
|
73
|
+
const address = (0, nexus_1.getAddress)({
|
|
74
|
+
owners: {
|
|
75
|
+
type: 'ecdsa',
|
|
76
|
+
accounts: [consts_1.accountA, consts_1.accountB],
|
|
77
|
+
},
|
|
78
|
+
initData: {
|
|
79
|
+
address: '0xBecba00993a919FfD35064a777E94643014A19Aa',
|
|
80
|
+
factory: '0x00000bb19a3579F4D779215dEf97AFbd0e30DB55',
|
|
81
|
+
factoryData: '0x0d51f0b7000000000000000000000000db8fca317427c3f85b6734af6455f287011c54b50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
|
82
|
+
intentExecutorInstalled: false,
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
(0, vitest_1.expect)(address).toEqual('0xBecba00993a919FfD35064a777E94643014A19Aa');
|
|
59
86
|
});
|
|
60
87
|
});
|
|
61
88
|
(0, vitest_1.describe)('Get Install Data', () => {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Abi, Address, Hex, PublicClient } from 'viem';
|
|
2
|
+
import { SmartAccount, SmartAccountImplementation } from 'viem/account-abstraction';
|
|
3
|
+
import { Module } from '../modules/common';
|
|
4
|
+
import { EnableSessionData } from '../modules/validators/smart-sessions';
|
|
5
|
+
import type { RhinestoneAccountConfig, Session } from '../types';
|
|
6
|
+
import { ValidatorConfig } from './utils';
|
|
7
|
+
declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
|
|
8
|
+
declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
|
|
9
|
+
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">>>;
|
|
10
|
+
declare function getInstallData(module: Module): `0x${string}`;
|
|
11
|
+
export { getAddress, packSignature, getSessionSmartAccount, getInstallData };
|
|
12
|
+
//# sourceMappingURL=passport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passport.d.ts","sourceRoot":"","sources":["../../../accounts/passport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAW,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAWpE,OAAO,EAIL,YAAY,EACZ,0BAA0B,EAE3B,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAK1C,OAAO,EACL,iBAAiB,EAIlB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,KAAK,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,EAAoC,eAAe,EAAE,MAAM,SAAS,CAAA;AAW3E,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,iBAsBlD;AAED,iBAAe,aAAa,CAC1B,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,eAAe,EAC1B,kBAAkB,GAAE,CAAC,SAAS,EAAE,GAAG,KAAK,GAA8B,0BAQvE;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,iEAuClC;AAmHD,iBAAS,cAAc,CAAC,MAAM,EAAE,MAAM,iBA2BrC;AAED,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,sBAAsB,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAddress = getAddress;
|
|
4
|
+
exports.packSignature = packSignature;
|
|
5
|
+
exports.getSessionSmartAccount = getSessionSmartAccount;
|
|
6
|
+
exports.getInstallData = getInstallData;
|
|
7
|
+
const viem_1 = require("viem");
|
|
8
|
+
const account_abstraction_1 = require("viem/account-abstraction");
|
|
9
|
+
const validators_1 = require("../modules/validators");
|
|
10
|
+
const smart_sessions_1 = require("../modules/validators/smart-sessions");
|
|
11
|
+
const utils_1 = require("./utils");
|
|
12
|
+
const CREATION_CODE = '0x6054600f3d396034805130553df3fe63906111273d3560e01c14602b57363d3d373d3d3d3d369030545af43d82803e156027573d90f35b3d90fd5b30543d5260203df3';
|
|
13
|
+
const PASSPORT_FACTORY_ADDRESS = '0xD70C6386Ca012CDeb249B4E46C53d3507D9CBB87';
|
|
14
|
+
const PASSPORT_MAIN_MODULE = '0x0d1Bf2f4Ab334324665aeb8d481fF92CdE289439';
|
|
15
|
+
function getAddress(config) {
|
|
16
|
+
const owners = config.owners;
|
|
17
|
+
if (!owners) {
|
|
18
|
+
throw new Error('Owners are required for passport');
|
|
19
|
+
}
|
|
20
|
+
if (owners.type !== 'ecdsa') {
|
|
21
|
+
throw new Error('Only ecdsa owners are supported for passport');
|
|
22
|
+
}
|
|
23
|
+
const ownerAccounts = owners.accounts.map((owner) => ({
|
|
24
|
+
weight: 1,
|
|
25
|
+
account: owner,
|
|
26
|
+
}));
|
|
27
|
+
const salt = encodeImageHash(owners.threshold ?? 1, ownerAccounts);
|
|
28
|
+
const accountInitData = (0, viem_1.padHex)(PASSPORT_MAIN_MODULE, { size: 32 });
|
|
29
|
+
const address = (0, viem_1.getContractAddress)({
|
|
30
|
+
opcode: 'CREATE2',
|
|
31
|
+
from: PASSPORT_FACTORY_ADDRESS,
|
|
32
|
+
salt,
|
|
33
|
+
bytecode: (0, viem_1.concat)([CREATION_CODE, accountInitData]),
|
|
34
|
+
});
|
|
35
|
+
return address;
|
|
36
|
+
}
|
|
37
|
+
async function packSignature(signature, validator, transformSignature = (signature) => signature) {
|
|
38
|
+
const validatorAddress = validator.address;
|
|
39
|
+
const packedSig = (0, viem_1.encodePacked)(['address', 'bytes'], [validatorAddress, transformSignature(signature)]);
|
|
40
|
+
return packedSig;
|
|
41
|
+
}
|
|
42
|
+
async function getSessionSmartAccount(client, address, session, validatorAddress, enableData, sign) {
|
|
43
|
+
return await getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
44
|
+
const dummyOpSignature = (0, validators_1.getMockSignature)(session.owners);
|
|
45
|
+
if (enableData) {
|
|
46
|
+
return (0, validators_1.encodeSmartSessionSignature)(smart_sessions_1.SMART_SESSION_MODE_ENABLE, (0, smart_sessions_1.getPermissionId)(session), dummyOpSignature, enableData);
|
|
47
|
+
}
|
|
48
|
+
return (0, validators_1.encodeSmartSessionSignature)(smart_sessions_1.SMART_SESSION_MODE_USE, (0, smart_sessions_1.getPermissionId)(session), dummyOpSignature);
|
|
49
|
+
}, async (hash) => {
|
|
50
|
+
const signature = await sign(hash);
|
|
51
|
+
if (enableData) {
|
|
52
|
+
return (0, validators_1.encodeSmartSessionSignature)(smart_sessions_1.SMART_SESSION_MODE_ENABLE, (0, smart_sessions_1.getPermissionId)(session), signature, enableData);
|
|
53
|
+
}
|
|
54
|
+
return (0, validators_1.encodeSmartSessionSignature)(smart_sessions_1.SMART_SESSION_MODE_USE, (0, smart_sessions_1.getPermissionId)(session), signature);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
async function getBaseSmartAccount(address, client, nonceValidatorAddress, getStubSignature, signUserOperation) {
|
|
58
|
+
return await (0, account_abstraction_1.toSmartAccount)({
|
|
59
|
+
client,
|
|
60
|
+
entryPoint: {
|
|
61
|
+
abi: account_abstraction_1.entryPoint07Abi,
|
|
62
|
+
address: account_abstraction_1.entryPoint07Address,
|
|
63
|
+
version: '0.7',
|
|
64
|
+
},
|
|
65
|
+
async decodeCalls() {
|
|
66
|
+
throw new Error('Not implemented');
|
|
67
|
+
},
|
|
68
|
+
async encodeCalls(calls) {
|
|
69
|
+
return (0, utils_1.encode7579Calls)({
|
|
70
|
+
mode: {
|
|
71
|
+
type: calls.length > 1 ? 'batchcall' : 'call',
|
|
72
|
+
revertOnError: false,
|
|
73
|
+
selector: '0x',
|
|
74
|
+
context: '0x',
|
|
75
|
+
},
|
|
76
|
+
callData: calls,
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
async getAddress() {
|
|
80
|
+
return address;
|
|
81
|
+
},
|
|
82
|
+
async getFactoryArgs() {
|
|
83
|
+
return {};
|
|
84
|
+
},
|
|
85
|
+
async getNonce(args) {
|
|
86
|
+
const validatorAddress = nonceValidatorAddress;
|
|
87
|
+
const TIMESTAMP_ADJUSTMENT = 16777215n; // max value for size 3
|
|
88
|
+
const defaultedKey = (args?.key ?? 0n) % TIMESTAMP_ADJUSTMENT;
|
|
89
|
+
const defaultedValidationMode = '0x00';
|
|
90
|
+
const key = (0, viem_1.concat)([
|
|
91
|
+
(0, viem_1.toHex)(defaultedKey, { size: 3 }),
|
|
92
|
+
defaultedValidationMode,
|
|
93
|
+
validatorAddress,
|
|
94
|
+
]);
|
|
95
|
+
return (0, utils_1.getAccountNonce)(client, {
|
|
96
|
+
address,
|
|
97
|
+
entryPointAddress: account_abstraction_1.entryPoint07Address,
|
|
98
|
+
key: BigInt(key),
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
async getStubSignature() {
|
|
102
|
+
return getStubSignature();
|
|
103
|
+
},
|
|
104
|
+
async signMessage() {
|
|
105
|
+
throw new Error('Not implemented');
|
|
106
|
+
},
|
|
107
|
+
async signTypedData() {
|
|
108
|
+
throw new Error('Not implemented');
|
|
109
|
+
},
|
|
110
|
+
async signUserOperation(parameters) {
|
|
111
|
+
const { chainId = client.chain?.id, ...userOperation } = parameters;
|
|
112
|
+
if (!chainId)
|
|
113
|
+
throw new Error('Chain id not found');
|
|
114
|
+
const hash = (0, account_abstraction_1.getUserOperationHash)({
|
|
115
|
+
userOperation: {
|
|
116
|
+
...userOperation,
|
|
117
|
+
sender: userOperation.sender ?? (await this.getAddress()),
|
|
118
|
+
signature: '0x',
|
|
119
|
+
},
|
|
120
|
+
entryPointAddress: account_abstraction_1.entryPoint07Address,
|
|
121
|
+
entryPointVersion: '0.7',
|
|
122
|
+
chainId: chainId,
|
|
123
|
+
});
|
|
124
|
+
return await signUserOperation(hash);
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function encodeImageHash(threshold, accounts) {
|
|
129
|
+
const sorted = accounts.sort((a, b) => a.account.address.toLowerCase() < b.account.address.toLowerCase() ? -1 : 1);
|
|
130
|
+
let imageHash = (0, viem_1.encodePacked)(['uint256'], [BigInt(threshold)]);
|
|
131
|
+
for (const account of sorted) {
|
|
132
|
+
imageHash = (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([
|
|
133
|
+
{
|
|
134
|
+
type: 'bytes32',
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
type: 'uint8',
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
type: 'address',
|
|
141
|
+
},
|
|
142
|
+
], [imageHash, account.weight, account.account.address]));
|
|
143
|
+
}
|
|
144
|
+
return imageHash;
|
|
145
|
+
}
|
|
146
|
+
function getInstallData(module) {
|
|
147
|
+
return (0, viem_1.encodeFunctionData)({
|
|
148
|
+
abi: [
|
|
149
|
+
{
|
|
150
|
+
type: 'function',
|
|
151
|
+
name: 'installModule',
|
|
152
|
+
inputs: [
|
|
153
|
+
{
|
|
154
|
+
type: 'uint256',
|
|
155
|
+
name: 'moduleTypeId',
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
type: 'address',
|
|
159
|
+
name: 'module',
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
type: 'bytes',
|
|
163
|
+
name: 'initData',
|
|
164
|
+
},
|
|
165
|
+
],
|
|
166
|
+
outputs: [],
|
|
167
|
+
stateMutability: 'nonpayable',
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
functionName: 'installModule',
|
|
171
|
+
args: [module.type, module.address, module.initData],
|
|
172
|
+
});
|
|
173
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../../../accounts/safe.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EACR,KAAK,OAAO,
|
|
1
|
+
{"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../../../accounts/safe.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EACR,KAAK,OAAO,EAOZ,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;AAK1E,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAgBhF,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;EA4FrD;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;AAwGD,OAAO,EACL,cAAc,EACd,UAAU,EACV,aAAa,EACb,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,uBAAuB,GACxB,CAAA"}
|