@rhinestone/sdk 1.0.41-alpha.0 → 1.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/accounts/error.d.ts +114 -0
- package/dist/src/accounts/error.d.ts.map +1 -0
- package/dist/src/accounts/error.js +174 -0
- package/dist/src/accounts/index.d.ts +50 -0
- package/dist/src/accounts/index.d.ts.map +1 -0
- package/dist/src/accounts/index.js +669 -0
- package/dist/src/accounts/index.test.d.ts +2 -0
- package/dist/src/accounts/index.test.d.ts.map +1 -0
- package/dist/src/accounts/index.test.js +33 -0
- 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 +20 -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 +33 -0
- package/dist/src/accounts/json-rpc/providers.d.ts +5 -0
- package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/providers.js +22 -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 +43 -0
- package/dist/src/accounts/kernel.d.ts +29 -0
- package/dist/src/accounts/kernel.d.ts.map +1 -0
- package/dist/src/accounts/kernel.js +297 -0
- package/dist/src/accounts/kernel.test.d.ts +2 -0
- package/dist/src/accounts/kernel.test.d.ts.map +1 -0
- package/dist/src/accounts/kernel.test.js +132 -0
- package/dist/src/accounts/nexus.d.ts +35 -0
- package/dist/src/accounts/nexus.d.ts.map +1 -0
- package/dist/src/accounts/nexus.js +471 -0
- package/dist/src/accounts/nexus.test.d.ts +2 -0
- package/dist/src/accounts/nexus.test.d.ts.map +1 -0
- package/dist/src/accounts/nexus.test.js +118 -0
- 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 +35 -0
- package/dist/src/accounts/safe.d.ts.map +1 -0
- package/dist/src/accounts/safe.js +365 -0
- package/dist/src/accounts/safe.test.d.ts +2 -0
- package/dist/src/accounts/safe.test.d.ts.map +1 -0
- package/dist/src/accounts/safe.test.js +118 -0
- 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 +183 -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 +36 -0
- package/dist/src/accounts/signing/passkeys.d.ts.map +1 -0
- package/dist/src/accounts/signing/passkeys.js +125 -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 +88 -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 +27 -0
- package/dist/src/accounts/startale.d.ts.map +1 -0
- package/dist/src/accounts/startale.js +116 -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 +92 -0
- package/dist/src/accounts/utils.d.ts +33 -0
- package/dist/src/accounts/utils.d.ts.map +1 -0
- package/dist/src/accounts/utils.js +208 -0
- package/dist/src/accounts/utils.test.d.ts +2 -0
- package/dist/src/accounts/utils.test.d.ts.map +1 -0
- package/dist/src/accounts/utils.test.js +49 -0
- package/dist/src/accounts/walletClient.d.ts +34 -0
- package/dist/src/accounts/walletClient.d.ts.map +1 -0
- package/dist/src/accounts/walletClient.js +121 -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/deployment.d.ts +19 -0
- package/dist/src/actions/deployment.d.ts.map +1 -0
- package/dist/src/actions/deployment.js +78 -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 +17 -0
- package/dist/src/actions/index.d.ts.map +1 -0
- package/dist/src/actions/index.js +53 -0
- 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 +14 -0
- package/dist/src/actions/smart-sessions.d.ts.map +1 -0
- package/dist/src/actions/smart-sessions.js +16 -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 +53 -0
- package/dist/src/execution/compact.d.ts +151 -0
- package/dist/src/execution/compact.d.ts.map +1 -0
- package/dist/src/execution/compact.js +122 -0
- package/dist/src/execution/error.d.ts +61 -0
- package/dist/src/execution/error.d.ts.map +1 -0
- package/dist/src/execution/error.js +87 -0
- package/dist/src/execution/index.d.ts +41 -0
- package/dist/src/execution/index.d.ts.map +1 -0
- package/dist/src/execution/index.js +233 -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/singleChainOps.d.ts +28 -0
- package/dist/src/execution/singleChainOps.d.ts.map +1 -0
- package/dist/src/execution/singleChainOps.js +32 -0
- package/dist/src/execution/smart-session.d.ts +13 -0
- package/dist/src/execution/smart-session.d.ts.map +1 -0
- package/dist/src/execution/smart-session.js +178 -0
- 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 +83 -0
- package/dist/src/execution/utils.d.ts.map +1 -0
- package/dist/src/execution/utils.js +705 -0
- package/dist/src/index.d.ts +74 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +317 -0
- package/dist/src/modules/abi/smart-sessions.d.ts +104 -0
- package/dist/src/modules/abi/smart-sessions.d.ts.map +1 -0
- package/dist/src/modules/abi/smart-sessions.js +131 -0
- package/dist/src/modules/chain-abstraction.d.ts +5 -0
- package/dist/src/modules/chain-abstraction.d.ts.map +1 -0
- package/dist/src/modules/chain-abstraction.js +7 -0
- package/dist/src/modules/common.d.ts +30 -0
- package/dist/src/modules/common.d.ts.map +1 -0
- package/dist/src/modules/common.js +42 -0
- package/dist/src/modules/index.d.ts +10 -0
- package/dist/src/modules/index.d.ts.map +1 -0
- package/dist/src/modules/index.js +94 -0
- package/dist/src/modules/index.test.d.ts +2 -0
- package/dist/src/modules/index.test.d.ts.map +1 -0
- package/dist/src/modules/index.test.js +81 -0
- package/dist/src/modules/legacy.d.ts +10 -0
- package/dist/src/modules/legacy.d.ts.map +1 -0
- package/dist/src/modules/legacy.js +65 -0
- package/dist/src/modules/read.d.ts +9 -0
- package/dist/src/modules/read.d.ts.map +1 -0
- package/dist/src/modules/read.js +125 -0
- package/dist/src/modules/validators/core.d.ts +29 -0
- package/dist/src/modules/validators/core.d.ts.map +1 -0
- package/dist/src/modules/validators/core.js +278 -0
- package/dist/src/modules/validators/core.test.d.ts +2 -0
- package/dist/src/modules/validators/core.test.d.ts.map +1 -0
- package/dist/src/modules/validators/core.test.js +101 -0
- package/dist/src/modules/validators/index.d.ts +4 -0
- package/dist/src/modules/validators/index.d.ts.map +1 -0
- package/dist/src/modules/validators/index.js +15 -0
- package/dist/src/modules/validators/smart-sessions.d.ts +96 -0
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -0
- package/dist/src/modules/validators/smart-sessions.js +497 -0
- package/dist/src/modules/validators/smart-sessions.test.d.ts +2 -0
- package/dist/src/modules/validators/smart-sessions.test.d.ts.map +1 -0
- package/dist/src/modules/validators/smart-sessions.test.js +219 -0
- package/dist/src/orchestrator/client.d.ts +27 -0
- package/dist/src/orchestrator/client.d.ts.map +1 -0
- package/dist/src/orchestrator/client.js +354 -0
- package/dist/src/orchestrator/consts.d.ts +5 -0
- package/dist/src/orchestrator/consts.d.ts.map +1 -0
- package/dist/src/orchestrator/consts.js +9 -0
- package/dist/src/orchestrator/error.d.ts +232 -0
- package/dist/src/orchestrator/error.d.ts.map +1 -0
- package/dist/src/orchestrator/error.js +268 -0
- package/dist/src/orchestrator/index.d.ts +10 -0
- package/dist/src/orchestrator/index.d.ts.map +1 -0
- package/dist/src/orchestrator/index.js +57 -0
- package/dist/src/orchestrator/registry.d.ts +22 -0
- package/dist/src/orchestrator/registry.d.ts.map +1 -0
- package/dist/src/orchestrator/registry.js +121 -0
- package/dist/src/orchestrator/registry.test.d.ts +2 -0
- package/dist/src/orchestrator/registry.test.d.ts.map +1 -0
- package/dist/src/orchestrator/registry.test.js +150 -0
- package/dist/src/orchestrator/types.d.ts +295 -0
- package/dist/src/orchestrator/types.d.ts.map +1 -0
- package/dist/src/orchestrator/types.js +17 -0
- package/dist/src/orchestrator/utils.d.ts +3 -0
- package/dist/src/orchestrator/utils.d.ts.map +1 -0
- package/dist/src/orchestrator/utils.js +24 -0
- package/dist/src/types.d.ts +284 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/utils/index.d.ts +26 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/utils/index.js +63 -0
- package/dist/test/consts.d.ts +10 -0
- package/dist/test/consts.d.ts.map +1 -0
- package/dist/test/consts.js +22 -0
- package/dist/test/utils/utils.d.ts +5 -0
- package/dist/test/utils/utils.d.ts.map +1 -0
- package/dist/test/utils/utils.js +20 -0
- package/package.json +1 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const consts_1 = require("../../test/consts");
|
|
5
|
+
const utils_1 = require("../../test/utils/utils");
|
|
6
|
+
const common_1 = require("../modules/common");
|
|
7
|
+
const kernel_1 = require("./kernel");
|
|
8
|
+
const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
9
|
+
(0, vitest_1.describe)('Accounts: Kernel', () => {
|
|
10
|
+
(0, vitest_1.describe)('Deploy Args', () => {
|
|
11
|
+
(0, vitest_1.test)('ECDSA owners', () => {
|
|
12
|
+
const deployArgs = (0, kernel_1.getDeployArgs)({
|
|
13
|
+
owners: {
|
|
14
|
+
type: 'ecdsa',
|
|
15
|
+
accounts: [consts_1.accountA, consts_1.accountB],
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
(0, utils_1.assertNotNull)(deployArgs);
|
|
19
|
+
const { factory, factoryData, salt, implementation, initializationCallData, } = deployArgs;
|
|
20
|
+
(0, vitest_1.expect)(factory).toEqual('0xd703aae79538628d27099b8c4f621be4ccd142d5');
|
|
21
|
+
(0, vitest_1.expect)(factoryData).toEqual('0xc5265d5d0000000000000000000000002577507b78c2008ff367261cb6285d44ba5ef2e90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003243c3b752b01000000000013fdb5234e4e3162a810f54d9f7e980000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000094000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
22
|
+
(0, vitest_1.expect)(salt).toEqual('0x0000000000000000000000000000000000000000000000000000000000000000');
|
|
23
|
+
(0, vitest_1.expect)(implementation).toEqual('0xd6CEDDe84be40893d153Be9d467CD6aD37875b28');
|
|
24
|
+
(0, vitest_1.expect)(initializationCallData).toEqual('0x3c3b752b01000000000013fdb5234e4e3162a810f54d9f7e980000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
25
|
+
});
|
|
26
|
+
(0, vitest_1.test)('Passkey owner', () => {
|
|
27
|
+
const deployArgs = (0, kernel_1.getDeployArgs)({
|
|
28
|
+
owners: {
|
|
29
|
+
type: 'passkey',
|
|
30
|
+
accounts: [consts_1.passkeyAccount],
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
(0, utils_1.assertNotNull)(deployArgs);
|
|
34
|
+
const { factory, factoryData, salt, implementation, initializationCallData, } = deployArgs;
|
|
35
|
+
(0, vitest_1.expect)(factory).toEqual('0xd703aae79538628d27099b8c4f621be4ccd142d5');
|
|
36
|
+
(0, vitest_1.expect)(factoryData).toEqual('0xc5265d5d0000000000000000000000002577507b78c2008ff367261cb6285d44ba5ef2e90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003443c3b752b010000000000578c4cb0e472a5462da43c495c3f330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000094000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
37
|
+
(0, vitest_1.expect)(salt).toEqual('0x0000000000000000000000000000000000000000000000000000000000000000');
|
|
38
|
+
(0, vitest_1.expect)(implementation).toEqual('0xd6CEDDe84be40893d153Be9d467CD6aD37875b28');
|
|
39
|
+
(0, vitest_1.expect)(initializationCallData).toEqual('0x3c3b752b010000000000578c4cb0e472a5462da43c495c3f330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
40
|
+
});
|
|
41
|
+
(0, vitest_1.test)('Existing account', () => {
|
|
42
|
+
const deployArgs = (0, kernel_1.getDeployArgs)({
|
|
43
|
+
owners: {
|
|
44
|
+
type: 'ecdsa',
|
|
45
|
+
accounts: [consts_1.accountA, consts_1.accountB],
|
|
46
|
+
},
|
|
47
|
+
initData: {
|
|
48
|
+
address: '0x86c4b9c9eA5df80D4e080e285015Cda47A503B51',
|
|
49
|
+
factory: '0xd703aaE79538628d27099B8c4f621bE4CCd142d5',
|
|
50
|
+
factoryData: '0xc5265d5d0000000000000000000000002577507b78c2008ff367261cb6285d44ba5ef2e90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001243c3b752b01845ADb2C711129d4f3966735eD98a9F09fC4cE570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001460098F8D98a9c55F21D17C26c78bF3D71Edc0E740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
|
51
|
+
intentExecutorInstalled: false,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
(0, utils_1.assertNotNull)(deployArgs);
|
|
55
|
+
const { factory, factoryData } = deployArgs;
|
|
56
|
+
(0, vitest_1.expect)(factory).toEqual('0xd703aaE79538628d27099B8c4f621bE4CCd142d5');
|
|
57
|
+
(0, vitest_1.expect)(factoryData).toEqual('0xc5265d5d0000000000000000000000002577507b78c2008ff367261cb6285d44ba5ef2e90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001243c3b752b01845ADb2C711129d4f3966735eD98a9F09fC4cE570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001460098F8D98a9c55F21D17C26c78bF3D71Edc0E740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
(0, vitest_1.describe)('Get Address', () => {
|
|
61
|
+
(0, vitest_1.test)('ECDSA owners', () => {
|
|
62
|
+
const address = (0, kernel_1.getAddress)({
|
|
63
|
+
owners: {
|
|
64
|
+
type: 'ecdsa',
|
|
65
|
+
accounts: [consts_1.accountA, consts_1.accountB],
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
(0, vitest_1.expect)(address).toEqual('0xC3733a544f5246a25405c7446e4D0C6b5762B22e');
|
|
69
|
+
});
|
|
70
|
+
(0, vitest_1.test)('Passkey owner', () => {
|
|
71
|
+
const address = (0, kernel_1.getAddress)({
|
|
72
|
+
owners: {
|
|
73
|
+
type: 'passkey',
|
|
74
|
+
accounts: [consts_1.passkeyAccount],
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
(0, vitest_1.expect)(address).toEqual('0xE48268B1C69528366d8eFaC5DB6fA947a7B52E55');
|
|
78
|
+
});
|
|
79
|
+
(0, vitest_1.test)('Existing account', () => {
|
|
80
|
+
const address = (0, kernel_1.getAddress)({
|
|
81
|
+
owners: {
|
|
82
|
+
type: 'ecdsa',
|
|
83
|
+
accounts: [consts_1.accountA, consts_1.accountB],
|
|
84
|
+
},
|
|
85
|
+
initData: {
|
|
86
|
+
address: '0x86c4b9c9eA5df80D4e080e285015Cda47A503B51',
|
|
87
|
+
factory: '0xd703aaE79538628d27099B8c4f621bE4CCd142d5',
|
|
88
|
+
factoryData: '0xc5265d5d0000000000000000000000002577507b78c2008ff367261cb6285d44ba5ef2e90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001243c3b752b01845ADb2C711129d4f3966735eD98a9F09fC4cE570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001460098F8D98a9c55F21D17C26c78bF3D71Edc0E740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
|
89
|
+
intentExecutorInstalled: false,
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
(0, vitest_1.expect)(address).toEqual('0x86c4b9c9eA5df80D4e080e285015Cda47A503B51');
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
(0, vitest_1.describe)('Get Install Data', () => {
|
|
96
|
+
(0, vitest_1.test)('Module', () => {
|
|
97
|
+
const installData = (0, kernel_1.getInstallData)({
|
|
98
|
+
address: MOCK_MODULE_ADDRESS,
|
|
99
|
+
initData: '0xabcd',
|
|
100
|
+
type: common_1.MODULE_TYPE_ID_VALIDATOR,
|
|
101
|
+
deInitData: '0x0000',
|
|
102
|
+
additionalContext: '0x0000',
|
|
103
|
+
});
|
|
104
|
+
(0, vitest_1.expect)(installData).toEqual([
|
|
105
|
+
'0x9517e29f000000000000000000000000000000000000000000000000000000000000000100000000000000000000000028de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000f40000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000002abcd00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
|
106
|
+
'0xb9b829410128de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f0000000000000000000000e9ae5c53000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001',
|
|
107
|
+
]);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
(0, vitest_1.describe)('Get Packed Signature', () => {
|
|
111
|
+
(0, vitest_1.describe)('Mock signature', () => {
|
|
112
|
+
(0, vitest_1.test)('Root validator', async () => {
|
|
113
|
+
const mockSignature = '0x1234';
|
|
114
|
+
const validator = {
|
|
115
|
+
address: '0xe35b75e5ec3c04e9cefa8e581fbee859f56edeb4',
|
|
116
|
+
isRoot: true,
|
|
117
|
+
};
|
|
118
|
+
const signature = await (0, kernel_1.packSignature)(mockSignature, validator);
|
|
119
|
+
(0, vitest_1.expect)(signature).toEqual('0x000555ad2729e8da1777a4e5020806f8bf7601c3db6bfe402f410a34958363a95a1234');
|
|
120
|
+
});
|
|
121
|
+
(0, vitest_1.test)('Non-root validator', async () => {
|
|
122
|
+
const mockSignature = '0x1234';
|
|
123
|
+
const validator = {
|
|
124
|
+
address: '0xe35b75e5ec3c04e9cefa8e581fbee859f56edeb4',
|
|
125
|
+
isRoot: false,
|
|
126
|
+
};
|
|
127
|
+
const signature = await (0, kernel_1.packSignature)(mockSignature, validator);
|
|
128
|
+
(0, vitest_1.expect)(signature).toEqual('0x01e35b75e5ec3c04e9cefa8e581fbee859f56edeb40555ad2729e8da1777a4e5020806f8bf7601c3db6bfe402f410a34958363a95a1234');
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Abi, Account, Address, Chain, Hex, PublicClient } from 'viem';
|
|
2
|
+
import { type SmartAccount, type SmartAccountImplementation } from 'viem/account-abstraction';
|
|
3
|
+
import type { Module } from '../modules/common';
|
|
4
|
+
import type { EnableSessionData } from '../modules/validators/smart-sessions';
|
|
5
|
+
import type { OwnerSet, RhinestoneAccountConfig, Session } from '../types';
|
|
6
|
+
import { type ValidatorConfig } from './utils';
|
|
7
|
+
declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
8
|
+
salt: `0x${string}`;
|
|
9
|
+
factory: `0x${string}`;
|
|
10
|
+
factoryData: `0x${string}`;
|
|
11
|
+
implementation: `0x${string}`;
|
|
12
|
+
initData: `0x${string}`;
|
|
13
|
+
initializationCallData: `0x${string}`;
|
|
14
|
+
} | null;
|
|
15
|
+
declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
|
|
16
|
+
declare function getEip712Domain(config: RhinestoneAccountConfig, chain: Chain): {
|
|
17
|
+
name: string;
|
|
18
|
+
version: string;
|
|
19
|
+
chainId: number;
|
|
20
|
+
verifyingContract: `0x${string}`;
|
|
21
|
+
salt: "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
22
|
+
};
|
|
23
|
+
declare function getInstallData(module: Module): `0x${string}`;
|
|
24
|
+
declare function getDefaultValidatorAddress(version: '1.0.2' | '1.2.0' | 'rhinestone-1.0.0-beta' | 'rhinestone-1.0.0' | undefined): Address;
|
|
25
|
+
declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex, defaultValidatorAddress?: Address): Promise<`0x${string}`>;
|
|
26
|
+
declare function getSmartAccount(client: PublicClient, address: Address, owners: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>, defaultValidatorAddress?: Address): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
27
|
+
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">>>;
|
|
28
|
+
declare function getGuardianSmartAccount(client: PublicClient, address: Address, guardians: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>, defaultValidatorAddress?: Address): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
29
|
+
declare function signEip7702InitData(config: RhinestoneAccountConfig, eoa: Account): Promise<`0x${string}`>;
|
|
30
|
+
declare function getEip7702InitCall(config: RhinestoneAccountConfig, signature: Hex): {
|
|
31
|
+
initData: `0x${string}`;
|
|
32
|
+
contract: `0x${string}`;
|
|
33
|
+
};
|
|
34
|
+
export { getEip712Domain, getInstallData, getAddress, getDefaultValidatorAddress, packSignature, getDeployArgs, getSmartAccount, getSessionSmartAccount, getGuardianSmartAccount, signEip7702InitData, getEip7702InitCall, };
|
|
35
|
+
//# sourceMappingURL=nexus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nexus.d.ts","sourceRoot":"","sources":["../../../accounts/nexus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAe3E,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,EAEV,QAAQ,EACR,uBAAuB,EACvB,OAAO,EACR,MAAM,UAAU,CAAA;AAMjB,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAqBhF,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;;SAqHrD;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,iBAsClD;AAED,iBAAS,eAAe,CAAC,MAAM,EAAE,uBAAuB,EAAE,KAAK,EAAE,KAAK;;;;;;EAarE;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,0BA8Bb;AAED,iBAAS,kBAAkB,CAAC,MAAM,EAAE,uBAAuB,EAAE,SAAS,EAAE,GAAG;;;EA0C1E;AA6FD,OAAO,EACL,eAAe,EACf,cAAc,EACd,UAAU,EACV,0BAA0B,EAC1B,aAAa,EACb,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,GACnB,CAAA"}
|
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEip712Domain = getEip712Domain;
|
|
4
|
+
exports.getInstallData = getInstallData;
|
|
5
|
+
exports.getAddress = getAddress;
|
|
6
|
+
exports.getDefaultValidatorAddress = getDefaultValidatorAddress;
|
|
7
|
+
exports.packSignature = packSignature;
|
|
8
|
+
exports.getDeployArgs = getDeployArgs;
|
|
9
|
+
exports.getSmartAccount = getSmartAccount;
|
|
10
|
+
exports.getSessionSmartAccount = getSessionSmartAccount;
|
|
11
|
+
exports.getGuardianSmartAccount = getGuardianSmartAccount;
|
|
12
|
+
exports.signEip7702InitData = signEip7702InitData;
|
|
13
|
+
exports.getEip7702InitCall = getEip7702InitCall;
|
|
14
|
+
const viem_1 = require("viem");
|
|
15
|
+
const account_abstraction_1 = require("viem/account-abstraction");
|
|
16
|
+
const modules_1 = require("../modules");
|
|
17
|
+
const validators_1 = require("../modules/validators");
|
|
18
|
+
const core_1 = require("../modules/validators/core");
|
|
19
|
+
const error_1 = require("./error");
|
|
20
|
+
const utils_1 = require("./utils");
|
|
21
|
+
const NEXUS_DEFAULT_VALIDATOR_ADDRESS = core_1.OWNABLE_VALIDATOR_ADDRESS;
|
|
22
|
+
const NEXUS_VERSION = '1.2.0';
|
|
23
|
+
const NEXUS_IMPLEMENTATION_ADDRESS = '0x000000000032dDC454C3BDcba80484Ad5A798705';
|
|
24
|
+
const NEXUS_FACTORY_ADDRESS = '0x0000000000679A258c64d2F20F310e12B64b7375';
|
|
25
|
+
const NEXUS_BOOTSTRAP_ADDRESS = '0x00000000006eFb61D8c9546FF1B500de3f244EA7';
|
|
26
|
+
const NEXUS_IMPLEMENTATION_1_0_0 = '0x000000039dfcad030719b07296710f045f0558f7';
|
|
27
|
+
const NEXUS_BOOTSTRAP_1_0_0 = '0x00000008c901d8871b6f6942de0b5d9ccf3873d3';
|
|
28
|
+
const NEXUS_K1_VALIDATOR = '0x00000004171351c442b202678c48d8ab5b321e8f';
|
|
29
|
+
const NEXUS_CREATION_CODE = '0x60806040526102aa803803806100148161018c565b92833981016040828203126101885781516001600160a01b03811692909190838303610188576020810151906001600160401b03821161018857019281601f8501121561018857835161006e610069826101c5565b61018c565b9481865260208601936020838301011161018857815f926020809301865e8601015260017f90b772c2cb8a51aa7a8a65fc23543c6d022d5b3f8e2b92eed79fba7eef8293005d823b15610176577f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b031916821790557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b5f80a282511561015e575f8091610146945190845af43d15610156573d91610137610069846101c5565b9283523d5f602085013e6101e0565b505b604051606b908161023f8239f35b6060916101e0565b50505034156101485763b398979f60e01b5f5260045ffd5b634c9c8ce360e01b5f5260045260245ffd5b5f80fd5b6040519190601f01601f191682016001600160401b038111838210176101b157604052565b634e487b7160e01b5f52604160045260245ffd5b6001600160401b0381116101b157601f01601f191660200190565b9061020457508051156101f557805190602001fd5b63d6bda27560e01b5f5260045ffd5b81511580610235575b610215575090565b639996b31560e01b5f9081526001600160a01b0391909116600452602490fd5b50803b1561020d56fe60806040523615605c575f8073ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416368280378136915af43d5f803e156058573d5ff35b3d5ffd5b00fea164736f6c634300081b000a';
|
|
30
|
+
function getDeployArgs(config) {
|
|
31
|
+
if (config.initData) {
|
|
32
|
+
if (!('factory' in config.initData)) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const { factory, factoryData } = config.initData;
|
|
36
|
+
const v1Result = tryDecodeV1FactoryData(factory, factoryData);
|
|
37
|
+
if (v1Result) {
|
|
38
|
+
return v1Result;
|
|
39
|
+
}
|
|
40
|
+
const v0Result = tryDecodeV0FactoryData(factory, factoryData);
|
|
41
|
+
if (v0Result) {
|
|
42
|
+
return v0Result;
|
|
43
|
+
}
|
|
44
|
+
throw new error_1.AccountConfigurationNotSupportedError('Invalid factory data: unrecognized schema', 'nexus');
|
|
45
|
+
}
|
|
46
|
+
const account = config.account;
|
|
47
|
+
const defaultSalt = (0, viem_1.keccak256)('0x');
|
|
48
|
+
const salt = account?.salt ?? defaultSalt;
|
|
49
|
+
const moduleSetup = (0, modules_1.getSetup)(config);
|
|
50
|
+
// Filter out the default validator
|
|
51
|
+
const defaultValidator = moduleSetup.validators.find((v) => v.address === NEXUS_DEFAULT_VALIDATOR_ADDRESS);
|
|
52
|
+
const defaultValidatorInitData = defaultValidator
|
|
53
|
+
? defaultValidator.initData
|
|
54
|
+
: '0x';
|
|
55
|
+
const validators = moduleSetup.validators.filter((v) => v.address !== NEXUS_DEFAULT_VALIDATOR_ADDRESS);
|
|
56
|
+
const bootstrapData = (0, viem_1.size)(defaultValidatorInitData)
|
|
57
|
+
? (0, viem_1.encodeFunctionData)({
|
|
58
|
+
abi: (0, viem_1.parseAbi)([
|
|
59
|
+
'struct BootstrapConfig {address module;bytes initData;}',
|
|
60
|
+
'struct BootstrapPreValidationHookConfig {uint256 hookType;address module;bytes data;}',
|
|
61
|
+
'function initNexusWithDefaultValidatorAndOtherModulesNoRegistry(bytes calldata defaultValidatorInitData,BootstrapConfig[] calldata validators,BootstrapConfig[] calldata executors,BootstrapConfig calldata hook,BootstrapConfig[] calldata fallbacks,BootstrapPreValidationHookConfig[] calldata preValidationHooks) external',
|
|
62
|
+
]),
|
|
63
|
+
functionName: 'initNexusWithDefaultValidatorAndOtherModulesNoRegistry',
|
|
64
|
+
args: [
|
|
65
|
+
defaultValidatorInitData,
|
|
66
|
+
validators.map((v) => ({
|
|
67
|
+
module: v.address,
|
|
68
|
+
initData: v.initData,
|
|
69
|
+
})),
|
|
70
|
+
moduleSetup.executors.map((e) => ({
|
|
71
|
+
module: e.address,
|
|
72
|
+
initData: e.initData,
|
|
73
|
+
})),
|
|
74
|
+
{
|
|
75
|
+
module: viem_1.zeroAddress,
|
|
76
|
+
initData: '0x',
|
|
77
|
+
},
|
|
78
|
+
moduleSetup.fallbacks.map((f) => ({
|
|
79
|
+
module: f.address,
|
|
80
|
+
initData: f.initData,
|
|
81
|
+
})),
|
|
82
|
+
[],
|
|
83
|
+
],
|
|
84
|
+
})
|
|
85
|
+
: (0, viem_1.encodeFunctionData)({
|
|
86
|
+
abi: (0, viem_1.parseAbi)([
|
|
87
|
+
'struct BootstrapConfig {address module;bytes initData;}',
|
|
88
|
+
'struct BootstrapPreValidationHookConfig {uint256 hookType;address module;bytes data;}',
|
|
89
|
+
'function initNexusNoRegistry(BootstrapConfig[] calldata validators,BootstrapConfig[] calldata executors,BootstrapConfig calldata hook,BootstrapConfig[] calldata fallbacks,BootstrapPreValidationHookConfig[] calldata preValidationHooks) external',
|
|
90
|
+
]),
|
|
91
|
+
functionName: 'initNexusNoRegistry',
|
|
92
|
+
args: [
|
|
93
|
+
validators.map((v) => ({
|
|
94
|
+
module: v.address,
|
|
95
|
+
initData: v.initData,
|
|
96
|
+
})),
|
|
97
|
+
moduleSetup.executors.map((e) => ({
|
|
98
|
+
module: e.address,
|
|
99
|
+
initData: e.initData,
|
|
100
|
+
})),
|
|
101
|
+
{
|
|
102
|
+
module: viem_1.zeroAddress,
|
|
103
|
+
initData: '0x',
|
|
104
|
+
},
|
|
105
|
+
moduleSetup.fallbacks.map((f) => ({
|
|
106
|
+
module: f.address,
|
|
107
|
+
initData: f.initData,
|
|
108
|
+
})),
|
|
109
|
+
[],
|
|
110
|
+
],
|
|
111
|
+
});
|
|
112
|
+
const initData = (0, viem_1.encodeAbiParameters)([{ type: 'address' }, { type: 'bytes' }], [NEXUS_BOOTSTRAP_ADDRESS, bootstrapData]);
|
|
113
|
+
const factoryData = (0, viem_1.encodeFunctionData)({
|
|
114
|
+
abi: (0, viem_1.parseAbi)(['function createAccount(bytes,bytes32)']),
|
|
115
|
+
functionName: 'createAccount',
|
|
116
|
+
args: [initData, salt],
|
|
117
|
+
});
|
|
118
|
+
const initializationCallData = (0, viem_1.encodeFunctionData)({
|
|
119
|
+
abi: (0, viem_1.parseAbi)(['function initializeAccount(bytes)']),
|
|
120
|
+
functionName: 'initializeAccount',
|
|
121
|
+
args: [initData],
|
|
122
|
+
});
|
|
123
|
+
return {
|
|
124
|
+
factory: NEXUS_FACTORY_ADDRESS,
|
|
125
|
+
factoryData,
|
|
126
|
+
salt,
|
|
127
|
+
implementation: NEXUS_IMPLEMENTATION_ADDRESS,
|
|
128
|
+
initializationCallData,
|
|
129
|
+
initData,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function getAddress(config) {
|
|
133
|
+
const deployArgs = getDeployArgs(config);
|
|
134
|
+
if (!deployArgs) {
|
|
135
|
+
if (config.initData?.address) {
|
|
136
|
+
return config.initData.address;
|
|
137
|
+
}
|
|
138
|
+
throw new Error('Cannot derive address: deploy args not available');
|
|
139
|
+
}
|
|
140
|
+
const { factory, salt, initializationCallData, implementation } = deployArgs;
|
|
141
|
+
const creationCode = factory === NEXUS_FACTORY_ADDRESS
|
|
142
|
+
? NEXUS_CREATION_CODE
|
|
143
|
+
: '0x603d3d8160223d3973000000039dfcad030719b07296710f045f0558f760095155f3363d3d373d3d363d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc545af43d6000803e6038573d6000fd5b3d6000f3';
|
|
144
|
+
const accountInitData = factory === NEXUS_FACTORY_ADDRESS
|
|
145
|
+
? (0, viem_1.encodeAbiParameters)([
|
|
146
|
+
{
|
|
147
|
+
name: 'address',
|
|
148
|
+
type: 'address',
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: 'calldata',
|
|
152
|
+
type: 'bytes',
|
|
153
|
+
},
|
|
154
|
+
], [implementation, initializationCallData])
|
|
155
|
+
: '0x';
|
|
156
|
+
const address = (0, viem_1.getContractAddress)({
|
|
157
|
+
opcode: 'CREATE2',
|
|
158
|
+
from: factory,
|
|
159
|
+
salt,
|
|
160
|
+
bytecode: (0, viem_1.concat)([creationCode, accountInitData]),
|
|
161
|
+
});
|
|
162
|
+
return address;
|
|
163
|
+
}
|
|
164
|
+
function getEip712Domain(config, chain) {
|
|
165
|
+
if (config.initData) {
|
|
166
|
+
throw new error_1.Eip712DomainNotAvailableError('Existing Nexus accounts are not yet supported');
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
name: 'Nexus',
|
|
170
|
+
version: NEXUS_VERSION,
|
|
171
|
+
chainId: chain.id,
|
|
172
|
+
verifyingContract: getAddress(config),
|
|
173
|
+
salt: viem_1.zeroHash,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function getInstallData(module) {
|
|
177
|
+
return (0, viem_1.encodeFunctionData)({
|
|
178
|
+
abi: [
|
|
179
|
+
{
|
|
180
|
+
type: 'function',
|
|
181
|
+
name: 'installModule',
|
|
182
|
+
inputs: [
|
|
183
|
+
{
|
|
184
|
+
type: 'uint256',
|
|
185
|
+
name: 'moduleTypeId',
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
type: 'address',
|
|
189
|
+
name: 'module',
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
type: 'bytes',
|
|
193
|
+
name: 'initData',
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
outputs: [],
|
|
197
|
+
stateMutability: 'nonpayable',
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
functionName: 'installModule',
|
|
201
|
+
args: [module.type, module.address, module.initData],
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
function getDefaultValidatorAddress(version) {
|
|
205
|
+
if (!version) {
|
|
206
|
+
return NEXUS_DEFAULT_VALIDATOR_ADDRESS;
|
|
207
|
+
}
|
|
208
|
+
switch (version) {
|
|
209
|
+
case '1.0.2':
|
|
210
|
+
return '0x0000002D6DB27c52E3C11c1Cf24072004AC75cBa';
|
|
211
|
+
case '1.2.0':
|
|
212
|
+
return '0x00000000d12897ddadc2044614a9677b191a2d95';
|
|
213
|
+
case 'rhinestone-1.0.0-beta':
|
|
214
|
+
return '0x0000000000e9e6e96bcaa3c113187cdb7e38aed9';
|
|
215
|
+
case 'rhinestone-1.0.0':
|
|
216
|
+
return NEXUS_DEFAULT_VALIDATOR_ADDRESS;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
async function packSignature(signature, validator, transformSignature = (signature) => signature, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
|
|
220
|
+
const validatorAddress = validator.address === defaultValidatorAddress
|
|
221
|
+
? viem_1.zeroAddress
|
|
222
|
+
: validator.address;
|
|
223
|
+
const packedSig = (0, viem_1.encodePacked)(['address', 'bytes'], [validatorAddress, transformSignature(signature)]);
|
|
224
|
+
return packedSig;
|
|
225
|
+
}
|
|
226
|
+
async function getSmartAccount(client, address, owners, validatorAddress, sign, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
|
|
227
|
+
return getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
228
|
+
return (0, validators_1.getMockSignature)(owners);
|
|
229
|
+
}, sign, defaultValidatorAddress);
|
|
230
|
+
}
|
|
231
|
+
async function getSessionSmartAccount(client, address, session, validatorAddress, enableData, sign, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
|
|
232
|
+
return await getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
233
|
+
const dummyOpSignature = (0, validators_1.getMockSignature)(session.owners);
|
|
234
|
+
if (enableData) {
|
|
235
|
+
return (0, validators_1.encodeSmartSessionSignature)(validators_1.SMART_SESSION_MODE_ENABLE, (0, validators_1.getPermissionId)(session), dummyOpSignature, enableData);
|
|
236
|
+
}
|
|
237
|
+
return (0, validators_1.encodeSmartSessionSignature)(validators_1.SMART_SESSION_MODE_USE, (0, validators_1.getPermissionId)(session), dummyOpSignature);
|
|
238
|
+
}, async (hash) => {
|
|
239
|
+
const signature = await sign(hash);
|
|
240
|
+
if (enableData) {
|
|
241
|
+
return (0, validators_1.encodeSmartSessionSignature)(validators_1.SMART_SESSION_MODE_ENABLE, (0, validators_1.getPermissionId)(session), signature, enableData);
|
|
242
|
+
}
|
|
243
|
+
return (0, validators_1.encodeSmartSessionSignature)(validators_1.SMART_SESSION_MODE_USE, (0, validators_1.getPermissionId)(session), signature);
|
|
244
|
+
}, defaultValidatorAddress);
|
|
245
|
+
}
|
|
246
|
+
async function getGuardianSmartAccount(client, address, guardians, validatorAddress, sign, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
|
|
247
|
+
return await getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
248
|
+
return (0, validators_1.getMockSignature)(guardians);
|
|
249
|
+
}, async (hash) => {
|
|
250
|
+
return await sign(hash);
|
|
251
|
+
}, defaultValidatorAddress);
|
|
252
|
+
}
|
|
253
|
+
async function getBaseSmartAccount(address, client, nonceValidatorAddress, getStubSignature, signUserOperation, defaultValidatorAddress) {
|
|
254
|
+
return await (0, account_abstraction_1.toSmartAccount)({
|
|
255
|
+
client,
|
|
256
|
+
entryPoint: {
|
|
257
|
+
abi: account_abstraction_1.entryPoint07Abi,
|
|
258
|
+
address: account_abstraction_1.entryPoint07Address,
|
|
259
|
+
version: '0.7',
|
|
260
|
+
},
|
|
261
|
+
async decodeCalls() {
|
|
262
|
+
throw new Error('Not implemented');
|
|
263
|
+
},
|
|
264
|
+
async encodeCalls(calls) {
|
|
265
|
+
return (0, utils_1.encode7579Calls)({
|
|
266
|
+
mode: {
|
|
267
|
+
type: calls.length > 1 ? 'batchcall' : 'call',
|
|
268
|
+
revertOnError: false,
|
|
269
|
+
selector: '0x',
|
|
270
|
+
context: '0x',
|
|
271
|
+
},
|
|
272
|
+
callData: calls,
|
|
273
|
+
});
|
|
274
|
+
},
|
|
275
|
+
async getAddress() {
|
|
276
|
+
return address;
|
|
277
|
+
},
|
|
278
|
+
async getFactoryArgs() {
|
|
279
|
+
return {};
|
|
280
|
+
},
|
|
281
|
+
async getNonce(args) {
|
|
282
|
+
const validatorAddress = nonceValidatorAddress === defaultValidatorAddress
|
|
283
|
+
? viem_1.zeroAddress
|
|
284
|
+
: nonceValidatorAddress;
|
|
285
|
+
const TIMESTAMP_ADJUSTMENT = 16777215n; // max value for size 3
|
|
286
|
+
const defaultedKey = (args?.key ?? 0n) % TIMESTAMP_ADJUSTMENT;
|
|
287
|
+
const defaultedValidationMode = '0x00';
|
|
288
|
+
const key = (0, viem_1.concat)([
|
|
289
|
+
(0, viem_1.toHex)(defaultedKey, { size: 3 }),
|
|
290
|
+
defaultedValidationMode,
|
|
291
|
+
validatorAddress,
|
|
292
|
+
]);
|
|
293
|
+
return (0, utils_1.getAccountNonce)(client, {
|
|
294
|
+
address,
|
|
295
|
+
entryPointAddress: account_abstraction_1.entryPoint07Address,
|
|
296
|
+
key: BigInt(key),
|
|
297
|
+
});
|
|
298
|
+
},
|
|
299
|
+
async getStubSignature() {
|
|
300
|
+
return getStubSignature();
|
|
301
|
+
},
|
|
302
|
+
async signMessage() {
|
|
303
|
+
throw new Error('Not implemented');
|
|
304
|
+
},
|
|
305
|
+
async signTypedData() {
|
|
306
|
+
throw new Error('Not implemented');
|
|
307
|
+
},
|
|
308
|
+
async signUserOperation(parameters) {
|
|
309
|
+
const { chainId = client.chain?.id, ...userOperation } = parameters;
|
|
310
|
+
if (!chainId)
|
|
311
|
+
throw new Error('Chain id not found');
|
|
312
|
+
const hash = (0, account_abstraction_1.getUserOperationHash)({
|
|
313
|
+
userOperation: {
|
|
314
|
+
...userOperation,
|
|
315
|
+
sender: userOperation.sender ?? (await this.getAddress()),
|
|
316
|
+
signature: '0x',
|
|
317
|
+
},
|
|
318
|
+
entryPointAddress: account_abstraction_1.entryPoint07Address,
|
|
319
|
+
entryPointVersion: '0.7',
|
|
320
|
+
chainId: chainId,
|
|
321
|
+
});
|
|
322
|
+
return await signUserOperation(hash);
|
|
323
|
+
},
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
async function signEip7702InitData(config, eoa) {
|
|
327
|
+
const deployArgs = getDeployArgs(config);
|
|
328
|
+
if (!deployArgs) {
|
|
329
|
+
throw new Error('Cannot sign EIP-7702 init data: deploy args not available');
|
|
330
|
+
}
|
|
331
|
+
const { initData } = deployArgs;
|
|
332
|
+
if (!eoa.signTypedData) {
|
|
333
|
+
throw new error_1.SigningNotSupportedForAccountError();
|
|
334
|
+
}
|
|
335
|
+
const signature = await eoa.signTypedData({
|
|
336
|
+
domain: {
|
|
337
|
+
name: 'Nexus',
|
|
338
|
+
version: NEXUS_VERSION,
|
|
339
|
+
},
|
|
340
|
+
types: {
|
|
341
|
+
Initialize: [
|
|
342
|
+
{ name: 'nexus', type: 'address' },
|
|
343
|
+
{ name: 'chainIds', type: 'uint256[]' },
|
|
344
|
+
{ name: 'initData', type: 'bytes' },
|
|
345
|
+
],
|
|
346
|
+
},
|
|
347
|
+
primaryType: 'Initialize',
|
|
348
|
+
message: {
|
|
349
|
+
nexus: NEXUS_IMPLEMENTATION_ADDRESS,
|
|
350
|
+
chainIds: [0n],
|
|
351
|
+
initData,
|
|
352
|
+
},
|
|
353
|
+
});
|
|
354
|
+
return signature;
|
|
355
|
+
}
|
|
356
|
+
function getEip7702InitCall(config, signature) {
|
|
357
|
+
function getEncodedData(initData) {
|
|
358
|
+
const chainIds = [0n];
|
|
359
|
+
const chainIdIndex = 0n;
|
|
360
|
+
const chainIdsLength = 1n;
|
|
361
|
+
const encodedData = (0, viem_1.encodePacked)(['uint256', 'uint256', 'uint256', 'bytes'], [chainIdIndex, chainIdsLength, chainIds[0], initData]);
|
|
362
|
+
return encodedData;
|
|
363
|
+
}
|
|
364
|
+
const deployArgs = getDeployArgs(config);
|
|
365
|
+
if (!deployArgs) {
|
|
366
|
+
throw new Error('Cannot get EIP-7702 init call: deploy args not available');
|
|
367
|
+
}
|
|
368
|
+
const { initData } = deployArgs;
|
|
369
|
+
const encodedData = getEncodedData(initData);
|
|
370
|
+
const accountFullData = (0, viem_1.concat)([signature, encodedData]);
|
|
371
|
+
const accountInitCallData = (0, viem_1.encodeFunctionData)({
|
|
372
|
+
abi: [
|
|
373
|
+
{
|
|
374
|
+
type: 'function',
|
|
375
|
+
inputs: [
|
|
376
|
+
{
|
|
377
|
+
type: 'bytes',
|
|
378
|
+
name: 'initData',
|
|
379
|
+
},
|
|
380
|
+
],
|
|
381
|
+
outputs: [],
|
|
382
|
+
stateMutability: 'nonpayable',
|
|
383
|
+
name: 'initializeAccount',
|
|
384
|
+
},
|
|
385
|
+
],
|
|
386
|
+
functionName: 'initializeAccount',
|
|
387
|
+
args: [accountFullData],
|
|
388
|
+
});
|
|
389
|
+
return {
|
|
390
|
+
initData: accountInitCallData,
|
|
391
|
+
contract: NEXUS_IMPLEMENTATION_ADDRESS,
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
function tryDecodeV1FactoryData(factory, factoryData) {
|
|
395
|
+
try {
|
|
396
|
+
const decoded = (0, viem_1.decodeFunctionData)({
|
|
397
|
+
abi: (0, viem_1.parseAbi)(['function createAccount(bytes,bytes32)']),
|
|
398
|
+
data: factoryData,
|
|
399
|
+
});
|
|
400
|
+
const initData = decoded.args[0];
|
|
401
|
+
const salt = decoded.args[1];
|
|
402
|
+
const initializationCallData = (0, viem_1.encodeFunctionData)({
|
|
403
|
+
abi: (0, viem_1.parseAbi)(['function initializeAccount(bytes)']),
|
|
404
|
+
functionName: 'initializeAccount',
|
|
405
|
+
args: [initData],
|
|
406
|
+
});
|
|
407
|
+
return {
|
|
408
|
+
salt,
|
|
409
|
+
factory,
|
|
410
|
+
factoryData,
|
|
411
|
+
implementation: NEXUS_IMPLEMENTATION_ADDRESS,
|
|
412
|
+
initData,
|
|
413
|
+
initializationCallData,
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
catch (error) {
|
|
417
|
+
if (isAbiDecodingError(error)) {
|
|
418
|
+
return null;
|
|
419
|
+
}
|
|
420
|
+
throw error;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
function tryDecodeV0FactoryData(factory, factoryData) {
|
|
424
|
+
try {
|
|
425
|
+
const decoded = (0, viem_1.decodeFunctionData)({
|
|
426
|
+
abi: (0, viem_1.parseAbi)([
|
|
427
|
+
'function createAccount(address eoaOwner,uint256 index,address[] attesters,uint8 threshold)',
|
|
428
|
+
]),
|
|
429
|
+
data: factoryData,
|
|
430
|
+
});
|
|
431
|
+
const owner = decoded.args[0];
|
|
432
|
+
const index = decoded.args[1];
|
|
433
|
+
const attesters = decoded.args[2];
|
|
434
|
+
const threshold = decoded.args[3];
|
|
435
|
+
const salt = (0, viem_1.keccak256)((0, viem_1.encodePacked)(['address', 'uint256', 'address[]', 'uint8'], [owner, index, attesters, threshold]));
|
|
436
|
+
const implementation = factory === NEXUS_FACTORY_ADDRESS
|
|
437
|
+
? NEXUS_IMPLEMENTATION_ADDRESS
|
|
438
|
+
: NEXUS_IMPLEMENTATION_1_0_0;
|
|
439
|
+
const registry = viem_1.zeroAddress;
|
|
440
|
+
const bootstrapData = (0, viem_1.encodeFunctionData)({
|
|
441
|
+
abi: (0, viem_1.parseAbi)([
|
|
442
|
+
'function initNexusWithSingleValidator(address validator,bytes data,address registry,address[] attesters,uint8 threshold)',
|
|
443
|
+
]),
|
|
444
|
+
functionName: 'initNexusWithSingleValidator',
|
|
445
|
+
args: [NEXUS_K1_VALIDATOR, owner, registry, attesters, threshold],
|
|
446
|
+
});
|
|
447
|
+
const initData = (0, viem_1.encodeAbiParameters)([{ type: 'address' }, { type: 'bytes' }], [NEXUS_BOOTSTRAP_1_0_0, bootstrapData]);
|
|
448
|
+
const initializationCallData = (0, viem_1.encodeFunctionData)({
|
|
449
|
+
abi: (0, viem_1.parseAbi)(['function initializeAccount(bytes)']),
|
|
450
|
+
functionName: 'initializeAccount',
|
|
451
|
+
args: [initData],
|
|
452
|
+
});
|
|
453
|
+
return {
|
|
454
|
+
salt,
|
|
455
|
+
factory,
|
|
456
|
+
factoryData,
|
|
457
|
+
implementation,
|
|
458
|
+
initData,
|
|
459
|
+
initializationCallData,
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
catch (error) {
|
|
463
|
+
if (isAbiDecodingError(error)) {
|
|
464
|
+
return null;
|
|
465
|
+
}
|
|
466
|
+
throw error;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
function isAbiDecodingError(error) {
|
|
470
|
+
return (error instanceof Error && error.name === 'AbiFunctionSignatureNotFoundError');
|
|
471
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nexus.test.d.ts","sourceRoot":"","sources":["../../../accounts/nexus.test.ts"],"names":[],"mappings":""}
|