@rhinestone/sdk 1.0.0-alpha.2 → 1.0.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/accounts/custom.d.ts +18 -0
- package/dist/src/accounts/custom.d.ts.map +1 -0
- package/dist/src/accounts/custom.js +121 -0
- package/dist/src/accounts/custom.test.d.ts +2 -0
- package/dist/src/accounts/custom.test.d.ts.map +1 -0
- package/dist/src/accounts/custom.test.js +64 -0
- package/dist/src/accounts/error.d.ts.map +1 -1
- package/dist/src/accounts/error.js +2 -0
- package/dist/src/accounts/index.d.ts +22 -13
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +192 -186
- package/dist/src/accounts/index.test.js +3 -3
- package/dist/src/accounts/json-rpc/index.d.ts +5 -0
- package/dist/src/accounts/json-rpc/index.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/index.js +16 -0
- package/dist/src/accounts/json-rpc/index.test.d.ts +2 -0
- package/dist/src/accounts/json-rpc/index.test.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/index.test.js +16 -0
- package/dist/src/accounts/json-rpc/providers.d.ts +4 -0
- package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/providers.js +14 -0
- package/dist/src/accounts/json-rpc/providers.test.d.ts +2 -0
- package/dist/src/accounts/json-rpc/providers.test.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/providers.test.js +15 -0
- package/dist/src/accounts/kernel.d.ts +9 -10
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +3 -14
- package/dist/src/accounts/kernel.test.js +10 -15
- package/dist/src/accounts/nexus.d.ts +14 -13
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +121 -93
- package/dist/src/accounts/nexus.test.js +13 -14
- package/dist/src/accounts/safe.d.ts +5 -7
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +25 -35
- package/dist/src/accounts/safe.test.js +9 -10
- package/dist/src/accounts/signing/common.d.ts +27 -0
- package/dist/src/accounts/signing/common.d.ts.map +1 -0
- package/dist/src/accounts/signing/common.js +142 -0
- package/dist/src/accounts/signing/message.d.ts +5 -0
- package/dist/src/accounts/signing/message.d.ts.map +1 -0
- package/dist/src/accounts/signing/message.js +47 -0
- package/dist/src/accounts/signing/passkeys.d.ts +29 -0
- package/dist/src/accounts/signing/passkeys.d.ts.map +1 -0
- package/dist/src/accounts/signing/passkeys.js +90 -0
- package/dist/src/accounts/signing/passkeys.test.d.ts +2 -0
- package/dist/src/accounts/signing/passkeys.test.d.ts.map +1 -0
- package/dist/src/accounts/signing/passkeys.test.js +73 -0
- package/dist/src/accounts/signing/typedData.d.ts +5 -0
- package/dist/src/accounts/signing/typedData.d.ts.map +1 -0
- package/dist/src/accounts/signing/typedData.js +35 -0
- package/dist/src/accounts/startale.d.ts +20 -0
- package/dist/src/accounts/startale.d.ts.map +1 -0
- package/dist/src/accounts/startale.js +100 -0
- package/dist/src/accounts/startale.test.d.ts +2 -0
- package/dist/src/accounts/startale.test.d.ts.map +1 -0
- package/dist/src/accounts/startale.test.js +96 -0
- package/dist/src/accounts/utils.d.ts +2 -1
- package/dist/src/accounts/utils.d.ts.map +1 -1
- package/dist/src/accounts/utils.js +7 -0
- package/dist/src/actions/index.d.ts +145 -7
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +373 -23
- package/dist/src/actions/index.test.js +35 -17
- package/dist/src/actions/smart-session.d.ts +8 -2
- package/dist/src/actions/smart-session.d.ts.map +1 -1
- package/dist/src/actions/smart-session.js +6 -0
- package/dist/src/execution/compact.d.ts +130 -3
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +94 -1
- package/dist/src/execution/error.d.ts +2 -9
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +4 -13
- package/dist/src/execution/index.d.ts +3 -4
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +35 -80
- package/dist/src/execution/smart-session.d.ts +1 -1
- package/dist/src/execution/smart-session.d.ts.map +1 -1
- package/dist/src/execution/smart-session.js +12 -17
- package/dist/src/execution/utils.d.ts +19 -14
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +222 -97
- package/dist/src/index.d.ts +17 -15
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +108 -21
- package/dist/src/modules/index.d.ts +3 -22
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +5 -65
- package/dist/src/modules/index.test.js +3 -17
- package/dist/src/modules/omni-account.d.ts +2 -4
- package/dist/src/modules/omni-account.d.ts.map +1 -1
- package/dist/src/modules/omni-account.js +4 -8
- package/dist/src/modules/read.d.ts +5 -6
- package/dist/src/modules/read.d.ts.map +1 -1
- package/dist/src/modules/read.js +7 -37
- package/dist/src/modules/validators/core.d.ts +8 -8
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +126 -42
- package/dist/src/modules/validators/core.test.js +7 -7
- package/dist/src/modules/validators/smart-sessions.d.ts +3 -3
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
- package/dist/src/modules/validators/smart-sessions.js +10 -9
- package/dist/src/modules/validators/smart-sessions.test.js +4 -4
- package/dist/src/orchestrator/client.d.ts +5 -3
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +159 -95
- package/dist/src/orchestrator/consts.d.ts +3 -2
- package/dist/src/orchestrator/consts.d.ts.map +1 -1
- package/dist/src/orchestrator/consts.js +4 -2
- package/dist/src/orchestrator/index.d.ts +3 -4
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +1 -9
- package/dist/src/orchestrator/registry.d.ts +10 -13
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +75 -395
- package/dist/src/orchestrator/registry.test.d.ts.map +1 -0
- package/dist/src/orchestrator/registry.test.js +137 -0
- package/dist/src/orchestrator/types.d.ts +78 -16
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/orchestrator/utils.d.ts +1 -3
- package/dist/src/orchestrator/utils.d.ts.map +1 -1
- package/dist/src/orchestrator/utils.js +0 -102
- package/dist/src/types.d.ts +69 -26
- package/dist/src/types.d.ts.map +1 -1
- package/dist/test/consts.d.ts +2 -2
- package/dist/test/consts.d.ts.map +1 -1
- package/package.json +2 -1
- package/dist/src/actions/registry.d.ts +0 -7
- package/dist/src/actions/registry.d.ts.map +0 -1
- package/dist/src/actions/registry.js +0 -7
- package/dist/src/actions/registry.test.d.ts.map +0 -1
- package/dist/src/actions/registry.test.js +0 -25
- package/dist/src/modules/registry.d.ts +0 -13
- package/dist/src/modules/registry.d.ts.map +0 -1
- package/dist/src/modules/registry.js +0 -67
- /package/dist/src/{actions → orchestrator}/registry.test.d.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../../../accounts/kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,
|
|
1
|
+
{"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../../../accounts/kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EACR,KAAK,OAAO,EAQZ,KAAK,GAAG,EAER,KAAK,YAAY,EAMlB,MAAM,MAAM,CAAA;AACb,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAEhC,MAAM,0BAA0B,CAAA;AAGjC,OAAO,EAKL,KAAK,MAAM,EACZ,MAAM,mBAAmB,CAAA;AAQ1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAC7E,OAAO,KAAK,EAAE,QAAQ,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAC1E,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAgBhF,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;EA4CrD;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,iBASlD;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,EAAE,CAsE7C;AAED,iBAAe,aAAa,CAC1B,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,eAAe,EAC1B,kBAAkB,GAAE,CAAC,SAAS,EAAE,GAAG,KAAK,GAA8B,0BAYvE;AAED,iBAAS,eAAe,CAAC,WAAW,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,GAAG,GAAG,CAoBnE;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,iEAYlC;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,iEA0ClC;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,iEAclC;AA+ED,OAAO,EACL,cAAc,EACd,UAAU,EACV,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,aAAa,EACb,eAAe,GAChB,CAAA"}
|
|
@@ -6,15 +6,13 @@ exports.getDeployArgs = getDeployArgs;
|
|
|
6
6
|
exports.getSmartAccount = getSmartAccount;
|
|
7
7
|
exports.getSessionSmartAccount = getSessionSmartAccount;
|
|
8
8
|
exports.getGuardianSmartAccount = getGuardianSmartAccount;
|
|
9
|
-
exports.
|
|
10
|
-
exports.
|
|
11
|
-
exports.getPackedSignature = getPackedSignature;
|
|
9
|
+
exports.packSignature = packSignature;
|
|
10
|
+
exports.wrapMessageHash = wrapMessageHash;
|
|
12
11
|
const viem_1 = require("viem");
|
|
13
12
|
const account_abstraction_1 = require("viem/account-abstraction");
|
|
14
13
|
const modules_1 = require("../modules");
|
|
15
14
|
const common_1 = require("../modules/common");
|
|
16
15
|
const validators_1 = require("../modules/validators");
|
|
17
|
-
const error_1 = require("./error");
|
|
18
16
|
const utils_1 = require("./utils");
|
|
19
17
|
const KERNEL_META_FACTORY_ADDRESS = '0xd703aae79538628d27099b8c4f621be4ccd142d5';
|
|
20
18
|
const KERNEL_IMPLEMENTATION_ADDRESS = '0xd6CEDDe84be40893d153Be9d467CD6aD37875b28';
|
|
@@ -129,17 +127,8 @@ function getInstallData(module) {
|
|
|
129
127
|
}
|
|
130
128
|
}
|
|
131
129
|
}
|
|
132
|
-
function
|
|
133
|
-
throw new error_1.Eip7702NotSupportedForAccountError('kernel');
|
|
134
|
-
}
|
|
135
|
-
function get7702SmartAccount() {
|
|
136
|
-
throw new error_1.Eip7702NotSupportedForAccountError('kernel');
|
|
137
|
-
}
|
|
138
|
-
async function getPackedSignature(signFn, hash, validator, accountAddress, transformSignature = (signature) => signature) {
|
|
130
|
+
async function packSignature(signature, validator, transformSignature = (signature) => signature) {
|
|
139
131
|
const vId = validator.isRoot ? '0x00' : (0, viem_1.concat)(['0x01', validator.address]);
|
|
140
|
-
const signature = validator.isRoot
|
|
141
|
-
? await signFn(wrapMessageHash(hash, accountAddress))
|
|
142
|
-
: await signFn(hash);
|
|
143
132
|
const magicValueSigReplayable = (0, viem_1.keccak256)((0, viem_1.toHex)('kernel.replayable.signature'));
|
|
144
133
|
const packedSig = (0, viem_1.concat)([
|
|
145
134
|
vId,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const viem_1 = require("viem");
|
|
4
3
|
const vitest_1 = require("vitest");
|
|
5
4
|
const consts_1 = require("../../test/consts");
|
|
6
5
|
const common_1 = require("../modules/common");
|
|
@@ -17,24 +16,24 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
17
16
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
18
17
|
});
|
|
19
18
|
(0, vitest_1.expect)(factory).toEqual('0xd703aae79538628d27099b8c4f621be4ccd142d5');
|
|
20
|
-
(0, vitest_1.expect)(factoryData).toEqual('
|
|
19
|
+
(0, vitest_1.expect)(factoryData).toEqual('0xc5265d5d0000000000000000000000002577507b78c2008ff367261cb6285d44ba5ef2e90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003243c3b752b01000000000013fdB5234E4E3162a810F54d9f7E980000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000094000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
21
20
|
(0, vitest_1.expect)(salt).toEqual('0x0000000000000000000000000000000000000000000000000000000000000000');
|
|
22
21
|
(0, vitest_1.expect)(implementation).toEqual('0xd6CEDDe84be40893d153Be9d467CD6aD37875b28');
|
|
23
|
-
(0, vitest_1.expect)(initializationCallData).toEqual('
|
|
22
|
+
(0, vitest_1.expect)(initializationCallData).toEqual('0x3c3b752b01000000000013fdB5234E4E3162a810F54d9f7E980000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da09948693600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
24
23
|
});
|
|
25
24
|
(0, vitest_1.test)('Passkey owner', () => {
|
|
26
25
|
const { factory, factoryData, salt, implementation, initializationCallData, } = (0, kernel_1.getDeployArgs)({
|
|
27
26
|
owners: {
|
|
28
27
|
type: 'passkey',
|
|
29
|
-
|
|
28
|
+
accounts: [consts_1.passkeyAccount],
|
|
30
29
|
},
|
|
31
30
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
32
31
|
});
|
|
33
32
|
(0, vitest_1.expect)(factory).toEqual('0xd703aae79538628d27099b8c4f621be4ccd142d5');
|
|
34
|
-
(0, vitest_1.expect)(factoryData).toEqual('
|
|
33
|
+
(0, vitest_1.expect)(factoryData).toEqual('0xc5265d5d0000000000000000000000002577507b78c2008ff367261cb6285d44ba5ef2e90000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003443c3b752b010000000000578c4cB0e472a5462da43C495C3F330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000094000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
35
34
|
(0, vitest_1.expect)(salt).toEqual('0x0000000000000000000000000000000000000000000000000000000000000000');
|
|
36
35
|
(0, vitest_1.expect)(implementation).toEqual('0xd6CEDDe84be40893d153Be9d467CD6aD37875b28');
|
|
37
|
-
(0, vitest_1.expect)(initializationCallData).toEqual('
|
|
36
|
+
(0, vitest_1.expect)(initializationCallData).toEqual('0x3c3b752b010000000000578c4cB0e472a5462da43C495C3F330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001249517e29f000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000005ad9ce1f5035fd62ca96cef16adaaf000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
|
|
38
37
|
});
|
|
39
38
|
});
|
|
40
39
|
(0, vitest_1.describe)('Get Address', () => {
|
|
@@ -46,17 +45,17 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
46
45
|
},
|
|
47
46
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
48
47
|
});
|
|
49
|
-
(0, vitest_1.expect)(address).toEqual('
|
|
48
|
+
(0, vitest_1.expect)(address).toEqual('0xC3733a544f5246a25405c7446e4D0C6b5762B22e');
|
|
50
49
|
});
|
|
51
50
|
(0, vitest_1.test)('Passkey owner', () => {
|
|
52
51
|
const address = (0, kernel_1.getAddress)({
|
|
53
52
|
owners: {
|
|
54
53
|
type: 'passkey',
|
|
55
|
-
|
|
54
|
+
accounts: [consts_1.passkeyAccount],
|
|
56
55
|
},
|
|
57
56
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
58
57
|
});
|
|
59
|
-
(0, vitest_1.expect)(address).toEqual('
|
|
58
|
+
(0, vitest_1.expect)(address).toEqual('0xE48268B1C69528366d8eFaC5DB6fA947a7B52E55');
|
|
60
59
|
});
|
|
61
60
|
});
|
|
62
61
|
(0, vitest_1.describe)('Get Install Data', () => {
|
|
@@ -77,25 +76,21 @@ const MOCK_MODULE_ADDRESS = '0x28de6501fa86f2e6cd0b33c3aabdaeb4a1b93f3f';
|
|
|
77
76
|
(0, vitest_1.describe)('Get Packed Signature', () => {
|
|
78
77
|
(0, vitest_1.describe)('Mock signature', () => {
|
|
79
78
|
(0, vitest_1.test)('Root validator', async () => {
|
|
80
|
-
const hash = (0, viem_1.keccak256)('0xabcd');
|
|
81
79
|
const mockSignature = '0x1234';
|
|
82
|
-
const accountAddress = '0xa80ed905adbd7cba128aaf64a1fa33a530b9b0aa';
|
|
83
80
|
const validator = {
|
|
84
81
|
address: '0xe35b75e5ec3c04e9cefa8e581fbee859f56edeb4',
|
|
85
82
|
isRoot: true,
|
|
86
83
|
};
|
|
87
|
-
const signature = await (0, kernel_1.
|
|
84
|
+
const signature = await (0, kernel_1.packSignature)(mockSignature, validator);
|
|
88
85
|
(0, vitest_1.expect)(signature).toEqual('0x000555ad2729e8da1777a4e5020806f8bf7601c3db6bfe402f410a34958363a95a1234');
|
|
89
86
|
});
|
|
90
87
|
(0, vitest_1.test)('Non-root validator', async () => {
|
|
91
|
-
const hash = (0, viem_1.keccak256)('0xabcd');
|
|
92
88
|
const mockSignature = '0x1234';
|
|
93
|
-
const accountAddress = '0xa80ed905adbd7cba128aaf64a1fa33a530b9b0aa';
|
|
94
89
|
const validator = {
|
|
95
90
|
address: '0xe35b75e5ec3c04e9cefa8e581fbee859f56edeb4',
|
|
96
91
|
isRoot: false,
|
|
97
92
|
};
|
|
98
|
-
const signature = await (0, kernel_1.
|
|
93
|
+
const signature = await (0, kernel_1.packSignature)(mockSignature, validator);
|
|
99
94
|
(0, vitest_1.expect)(signature).toEqual('0x01e35b75e5ec3c04e9cefa8e581fbee859f56edeb40555ad2729e8da1777a4e5020806f8bf7601c3db6bfe402f410a34958363a95a1234');
|
|
100
95
|
});
|
|
101
96
|
});
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import type { Abi, Account, Address, Hex, PublicClient } from 'viem';
|
|
2
2
|
import { type SmartAccount, type SmartAccountImplementation } from 'viem/account-abstraction';
|
|
3
|
-
import { Module } from '../modules/common';
|
|
4
|
-
import { EnableSessionData } from '../modules/validators/smart-sessions';
|
|
3
|
+
import type { Module } from '../modules/common';
|
|
4
|
+
import type { EnableSessionData } from '../modules/validators/smart-sessions';
|
|
5
5
|
import type { OwnerSet, RhinestoneAccountConfig, Session } from '../types';
|
|
6
|
-
import { ValidatorConfig } from './utils';
|
|
6
|
+
import { type ValidatorConfig } from './utils';
|
|
7
7
|
declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
8
8
|
factory: `0x${string}`;
|
|
9
9
|
factoryData: `0x${string}`;
|
|
10
10
|
salt: `0x${string}`;
|
|
11
11
|
implementation: `0x${string}`;
|
|
12
12
|
initializationCallData: `0x${string}`;
|
|
13
|
+
initData: `0x${string}`;
|
|
13
14
|
};
|
|
14
15
|
declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
|
|
15
16
|
declare function getInstallData(module: Module): `0x${string}`;
|
|
16
|
-
declare function
|
|
17
|
-
declare function getSmartAccount(client: PublicClient, address: Address, owners: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex
|
|
18
|
-
declare function getSessionSmartAccount(client: PublicClient, address: Address, session: Session, validatorAddress: Address, enableData: EnableSessionData | null, sign: (hash: Hex) => Promise<Hex
|
|
19
|
-
declare function getGuardianSmartAccount(client: PublicClient, address: Address, guardians: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex
|
|
20
|
-
declare function
|
|
21
|
-
declare function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
export { getInstallData, getAddress,
|
|
17
|
+
declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex, defaultValidatorAddress?: Address): Promise<`0x${string}`>;
|
|
18
|
+
declare function getSmartAccount(client: PublicClient, address: Address, owners: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>, defaultValidatorAddress?: Address): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
19
|
+
declare function getSessionSmartAccount(client: PublicClient, address: Address, session: Session, validatorAddress: Address, enableData: EnableSessionData | null, sign: (hash: Hex) => Promise<Hex>, defaultValidatorAddress?: Address): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
20
|
+
declare function getGuardianSmartAccount(client: PublicClient, address: Address, guardians: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>, defaultValidatorAddress?: Address): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
21
|
+
declare function signEip7702InitData(config: RhinestoneAccountConfig, eoa: Account): Promise<`0x${string}`>;
|
|
22
|
+
declare function getEip7702InitCall(config: RhinestoneAccountConfig, signature: Hex): Promise<{
|
|
23
|
+
initData: `0x${string}`;
|
|
24
|
+
contract: `0x${string}`;
|
|
25
|
+
}>;
|
|
26
|
+
export { getInstallData, getAddress, packSignature, getDeployArgs, getSmartAccount, getSessionSmartAccount, getGuardianSmartAccount, signEip7702InitData, getEip7702InitCall, };
|
|
26
27
|
//# sourceMappingURL=nexus.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nexus.d.ts","sourceRoot":"","sources":["../../../accounts/nexus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;
|
|
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;AAapE,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAEhC,MAAM,0BAA0B,CAAA;AAGjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAS/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAC7E,OAAO,KAAK,EAAE,QAAQ,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAE1E,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAchF,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;;EA6FrD;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,iBA4BlD;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,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,aAAa,EACb,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,GACnB,CAAA"}
|
|
@@ -2,39 +2,45 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getInstallData = getInstallData;
|
|
4
4
|
exports.getAddress = getAddress;
|
|
5
|
-
exports.
|
|
5
|
+
exports.packSignature = packSignature;
|
|
6
6
|
exports.getDeployArgs = getDeployArgs;
|
|
7
7
|
exports.getSmartAccount = getSmartAccount;
|
|
8
8
|
exports.getSessionSmartAccount = getSessionSmartAccount;
|
|
9
9
|
exports.getGuardianSmartAccount = getGuardianSmartAccount;
|
|
10
|
-
exports.
|
|
11
|
-
exports.
|
|
10
|
+
exports.signEip7702InitData = signEip7702InitData;
|
|
11
|
+
exports.getEip7702InitCall = getEip7702InitCall;
|
|
12
12
|
const viem_1 = require("viem");
|
|
13
13
|
const account_abstraction_1 = require("viem/account-abstraction");
|
|
14
14
|
const modules_1 = require("../modules");
|
|
15
15
|
const validators_1 = require("../modules/validators");
|
|
16
|
+
const core_1 = require("../modules/validators/core");
|
|
16
17
|
const error_1 = require("./error");
|
|
17
18
|
const utils_1 = require("./utils");
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
19
|
+
const NEXUS_DEFAULT_VALIDATOR_ADDRESS = core_1.OWNABLE_VALIDATOR_ADDRESS;
|
|
20
|
+
const NEXUS_IMPLEMENTATION_ADDRESS = '0x000000000032dDC454C3BDcba80484Ad5A798705';
|
|
21
|
+
const NEXUS_FACTORY_ADDRESS = '0x0000000000679A258c64d2F20F310e12B64b7375';
|
|
22
|
+
const NEXUS_BOOTSTRAP_ADDRESS = '0x00000000006eFb61D8c9546FF1B500de3f244EA7';
|
|
22
23
|
const NEXUS_CREATION_CODE = '0x60806040526102aa803803806100148161018c565b92833981016040828203126101885781516001600160a01b03811692909190838303610188576020810151906001600160401b03821161018857019281601f8501121561018857835161006e610069826101c5565b61018c565b9481865260208601936020838301011161018857815f926020809301865e8601015260017f90b772c2cb8a51aa7a8a65fc23543c6d022d5b3f8e2b92eed79fba7eef8293005d823b15610176577f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b031916821790557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b5f80a282511561015e575f8091610146945190845af43d15610156573d91610137610069846101c5565b9283523d5f602085013e6101e0565b505b604051606b908161023f8239f35b6060916101e0565b50505034156101485763b398979f60e01b5f5260045ffd5b634c9c8ce360e01b5f5260045260245ffd5b5f80fd5b6040519190601f01601f191682016001600160401b038111838210176101b157604052565b634e487b7160e01b5f52604160045260245ffd5b6001600160401b0381116101b157601f01601f191660200190565b9061020457508051156101f557805190602001fd5b63d6bda27560e01b5f5260045ffd5b81511580610235575b610215575090565b639996b31560e01b5f9081526001600160a01b0391909116600452602490fd5b50803b1561020d56fe60806040523615605c575f8073ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416368280378136915af43d5f803e156058573d5ff35b3d5ffd5b00fea164736f6c634300081b000a';
|
|
23
24
|
function getDeployArgs(config) {
|
|
24
25
|
const salt = (0, viem_1.keccak256)('0x');
|
|
25
26
|
const moduleSetup = (0, modules_1.getSetup)(config);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
// Filter out the default validator
|
|
28
|
+
const defaultValidator = moduleSetup.validators.find((v) => v.address === NEXUS_DEFAULT_VALIDATOR_ADDRESS);
|
|
29
|
+
const defaultValidatorInitData = defaultValidator
|
|
30
|
+
? defaultValidator.initData
|
|
31
|
+
: '0x';
|
|
32
|
+
const validators = moduleSetup.validators.filter((v) => v.address !== NEXUS_DEFAULT_VALIDATOR_ADDRESS);
|
|
33
|
+
const bootstrapData = (0, viem_1.size)(defaultValidatorInitData)
|
|
34
|
+
? (0, viem_1.encodeFunctionData)({
|
|
29
35
|
abi: (0, viem_1.parseAbi)([
|
|
30
36
|
'struct BootstrapConfig {address module;bytes initData;}',
|
|
31
37
|
'struct BootstrapPreValidationHookConfig {uint256 hookType;address module;bytes data;}',
|
|
32
|
-
'
|
|
33
|
-
'function initNexus(BootstrapConfig[] calldata validators,BootstrapConfig[] calldata executors,BootstrapConfig calldata hook,BootstrapConfig[] calldata fallbacks,BootstrapPreValidationHookConfig[] calldata preValidationHooks,RegistryConfig registryConfig) external',
|
|
38
|
+
'function initNexusWithDefaultValidatorAndOtherModulesNoRegistry(bytes calldata defaultValidatorInitData,BootstrapConfig[] calldata validators,BootstrapConfig[] calldata executors,BootstrapConfig calldata hook,BootstrapConfig[] calldata fallbacks,BootstrapPreValidationHookConfig[] calldata preValidationHooks) external',
|
|
34
39
|
]),
|
|
35
|
-
functionName: '
|
|
40
|
+
functionName: 'initNexusWithDefaultValidatorAndOtherModulesNoRegistry',
|
|
36
41
|
args: [
|
|
37
|
-
|
|
42
|
+
defaultValidatorInitData,
|
|
43
|
+
validators.map((v) => ({
|
|
38
44
|
module: v.address,
|
|
39
45
|
initData: v.initData,
|
|
40
46
|
})),
|
|
@@ -51,14 +57,36 @@ function getDeployArgs(config) {
|
|
|
51
57
|
initData: f.initData,
|
|
52
58
|
})),
|
|
53
59
|
[],
|
|
60
|
+
],
|
|
61
|
+
})
|
|
62
|
+
: (0, viem_1.encodeFunctionData)({
|
|
63
|
+
abi: (0, viem_1.parseAbi)([
|
|
64
|
+
'struct BootstrapConfig {address module;bytes initData;}',
|
|
65
|
+
'struct BootstrapPreValidationHookConfig {uint256 hookType;address module;bytes data;}',
|
|
66
|
+
'function initNexusNoRegistry(BootstrapConfig[] calldata validators,BootstrapConfig[] calldata executors,BootstrapConfig calldata hook,BootstrapConfig[] calldata fallbacks,BootstrapPreValidationHookConfig[] calldata preValidationHooks) external',
|
|
67
|
+
]),
|
|
68
|
+
functionName: 'initNexusNoRegistry',
|
|
69
|
+
args: [
|
|
70
|
+
validators.map((v) => ({
|
|
71
|
+
module: v.address,
|
|
72
|
+
initData: v.initData,
|
|
73
|
+
})),
|
|
74
|
+
moduleSetup.executors.map((e) => ({
|
|
75
|
+
module: e.address,
|
|
76
|
+
initData: e.initData,
|
|
77
|
+
})),
|
|
54
78
|
{
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
threshold: moduleSetup.threshold,
|
|
79
|
+
module: viem_1.zeroAddress,
|
|
80
|
+
initData: '0x',
|
|
58
81
|
},
|
|
82
|
+
moduleSetup.fallbacks.map((f) => ({
|
|
83
|
+
module: f.address,
|
|
84
|
+
initData: f.initData,
|
|
85
|
+
})),
|
|
86
|
+
[],
|
|
59
87
|
],
|
|
60
|
-
})
|
|
61
|
-
]);
|
|
88
|
+
});
|
|
89
|
+
const initData = (0, viem_1.encodeAbiParameters)([{ type: 'address' }, { type: 'bytes' }], [NEXUS_BOOTSTRAP_ADDRESS, bootstrapData]);
|
|
62
90
|
const factoryData = (0, viem_1.encodeFunctionData)({
|
|
63
91
|
abi: (0, viem_1.parseAbi)(['function createAccount(bytes,bytes32)']),
|
|
64
92
|
functionName: 'createAccount',
|
|
@@ -75,6 +103,7 @@ function getDeployArgs(config) {
|
|
|
75
103
|
salt,
|
|
76
104
|
implementation: NEXUS_IMPLEMENTATION_ADDRESS,
|
|
77
105
|
initializationCallData,
|
|
106
|
+
initData,
|
|
78
107
|
};
|
|
79
108
|
}
|
|
80
109
|
function getAddress(config) {
|
|
@@ -122,17 +151,19 @@ function getInstallData(module) {
|
|
|
122
151
|
args: [module.type, module.address, module.initData],
|
|
123
152
|
});
|
|
124
153
|
}
|
|
125
|
-
async function
|
|
126
|
-
const
|
|
127
|
-
|
|
154
|
+
async function packSignature(signature, validator, transformSignature = (signature) => signature, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
|
|
155
|
+
const validatorAddress = validator.address === defaultValidatorAddress
|
|
156
|
+
? viem_1.zeroAddress
|
|
157
|
+
: validator.address;
|
|
158
|
+
const packedSig = (0, viem_1.encodePacked)(['address', 'bytes'], [validatorAddress, transformSignature(signature)]);
|
|
128
159
|
return packedSig;
|
|
129
160
|
}
|
|
130
|
-
async function getSmartAccount(client, address, owners, validatorAddress, sign) {
|
|
161
|
+
async function getSmartAccount(client, address, owners, validatorAddress, sign, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
|
|
131
162
|
return getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
132
163
|
return (0, validators_1.getMockSignature)(owners);
|
|
133
|
-
}, sign);
|
|
164
|
+
}, sign, defaultValidatorAddress);
|
|
134
165
|
}
|
|
135
|
-
async function getSessionSmartAccount(client, address, session, validatorAddress, enableData, sign) {
|
|
166
|
+
async function getSessionSmartAccount(client, address, session, validatorAddress, enableData, sign, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
|
|
136
167
|
return await getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
137
168
|
const dummyOpSignature = (0, validators_1.getMockSignature)(session.owners);
|
|
138
169
|
if (enableData) {
|
|
@@ -145,29 +176,16 @@ async function getSessionSmartAccount(client, address, session, validatorAddress
|
|
|
145
176
|
return (0, validators_1.encodeSmartSessionSignature)(validators_1.SMART_SESSION_MODE_ENABLE, (0, validators_1.getPermissionId)(session), signature, enableData);
|
|
146
177
|
}
|
|
147
178
|
return (0, validators_1.encodeSmartSessionSignature)(validators_1.SMART_SESSION_MODE_USE, (0, validators_1.getPermissionId)(session), signature);
|
|
148
|
-
});
|
|
179
|
+
}, defaultValidatorAddress);
|
|
149
180
|
}
|
|
150
|
-
async function getGuardianSmartAccount(client, address, guardians, validatorAddress, sign) {
|
|
181
|
+
async function getGuardianSmartAccount(client, address, guardians, validatorAddress, sign, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
|
|
151
182
|
return await getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
152
183
|
return (0, validators_1.getMockSignature)(guardians);
|
|
153
184
|
}, async (hash) => {
|
|
154
185
|
return await sign(hash);
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
async function get7702SmartAccount(account, client) {
|
|
158
|
-
return await getBaseSmartAccount(account.address, client, viem_1.zeroAddress, async () => {
|
|
159
|
-
const dynamicPart = K1_MEE_VALIDATOR_ADDRESS.substring(2).padEnd(40, '0');
|
|
160
|
-
return `0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000${dynamicPart}000000000000000000000000000000000000000000000000000000000000004181d4b4981670cb18f99f0b4a66446df1bf5b204d24cfcb659bf38ba27a4359b5711649ec2423c5e1247245eba2964679b6a1dbb85c992ae40b9b00c6935b02ff1b00000000000000000000000000000000000000000000000000000000000000`;
|
|
161
|
-
}, async (hash) => {
|
|
162
|
-
if (!account.signMessage) {
|
|
163
|
-
throw new error_1.SignMessageNotSupportedByAccountError();
|
|
164
|
-
}
|
|
165
|
-
return await account.signMessage({
|
|
166
|
-
message: { raw: hash },
|
|
167
|
-
});
|
|
168
|
-
});
|
|
186
|
+
}, defaultValidatorAddress);
|
|
169
187
|
}
|
|
170
|
-
async function getBaseSmartAccount(address, client, nonceValidatorAddress, getStubSignature, signUserOperation) {
|
|
188
|
+
async function getBaseSmartAccount(address, client, nonceValidatorAddress, getStubSignature, signUserOperation, defaultValidatorAddress) {
|
|
171
189
|
return await (0, account_abstraction_1.toSmartAccount)({
|
|
172
190
|
client,
|
|
173
191
|
entryPoint: {
|
|
@@ -196,13 +214,16 @@ async function getBaseSmartAccount(address, client, nonceValidatorAddress, getSt
|
|
|
196
214
|
return {};
|
|
197
215
|
},
|
|
198
216
|
async getNonce(args) {
|
|
217
|
+
const validatorAddress = nonceValidatorAddress === defaultValidatorAddress
|
|
218
|
+
? viem_1.zeroAddress
|
|
219
|
+
: nonceValidatorAddress;
|
|
199
220
|
const TIMESTAMP_ADJUSTMENT = 16777215n; // max value for size 3
|
|
200
221
|
const defaultedKey = (args?.key ?? 0n) % TIMESTAMP_ADJUSTMENT;
|
|
201
222
|
const defaultedValidationMode = '0x00';
|
|
202
223
|
const key = (0, viem_1.concat)([
|
|
203
224
|
(0, viem_1.toHex)(defaultedKey, { size: 3 }),
|
|
204
225
|
defaultedValidationMode,
|
|
205
|
-
|
|
226
|
+
validatorAddress,
|
|
206
227
|
]);
|
|
207
228
|
return (0, utils_1.getAccountNonce)(client, {
|
|
208
229
|
address,
|
|
@@ -237,56 +258,63 @@ async function getBaseSmartAccount(address, client, nonceValidatorAddress, getSt
|
|
|
237
258
|
},
|
|
238
259
|
});
|
|
239
260
|
}
|
|
240
|
-
function
|
|
241
|
-
const
|
|
242
|
-
if (!eoa) {
|
|
243
|
-
throw new error_1.
|
|
261
|
+
async function signEip7702InitData(config, eoa) {
|
|
262
|
+
const { initData } = getDeployArgs(config);
|
|
263
|
+
if (!eoa.signTypedData) {
|
|
264
|
+
throw new error_1.SigningNotSupportedForAccountError();
|
|
244
265
|
}
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
266
|
+
const signature = await eoa.signTypedData({
|
|
267
|
+
domain: {
|
|
268
|
+
name: 'Nexus',
|
|
269
|
+
version: '1.2.0',
|
|
270
|
+
},
|
|
271
|
+
types: {
|
|
272
|
+
Initialize: [
|
|
273
|
+
{ name: 'nexus', type: 'address' },
|
|
274
|
+
{ name: 'chainIds', type: 'uint256[]' },
|
|
275
|
+
{ name: 'initData', type: 'bytes' },
|
|
276
|
+
],
|
|
277
|
+
},
|
|
278
|
+
primaryType: 'Initialize',
|
|
279
|
+
message: {
|
|
280
|
+
nexus: NEXUS_IMPLEMENTATION_ADDRESS,
|
|
281
|
+
chainIds: [0n],
|
|
282
|
+
initData,
|
|
260
283
|
},
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
284
|
+
});
|
|
285
|
+
return signature;
|
|
286
|
+
}
|
|
287
|
+
async function getEip7702InitCall(config, signature) {
|
|
288
|
+
function getEncodedData(initData) {
|
|
289
|
+
const chainIds = [0n];
|
|
290
|
+
const chainIdIndex = 0n;
|
|
291
|
+
const chainIdsLength = 1n;
|
|
292
|
+
const encodedData = (0, viem_1.encodePacked)(['uint256', 'uint256', 'uint256', 'bytes'], [chainIdIndex, chainIdsLength, chainIds[0], initData]);
|
|
293
|
+
return encodedData;
|
|
294
|
+
}
|
|
295
|
+
const { initData } = getDeployArgs(config);
|
|
296
|
+
const encodedData = getEncodedData(initData);
|
|
297
|
+
const accountFullData = (0, viem_1.concat)([signature, encodedData]);
|
|
298
|
+
const accountInitCallData = (0, viem_1.encodeFunctionData)({
|
|
299
|
+
abi: [
|
|
300
|
+
{
|
|
301
|
+
type: 'function',
|
|
302
|
+
inputs: [
|
|
303
|
+
{
|
|
304
|
+
type: 'bytes',
|
|
305
|
+
name: 'initData',
|
|
306
|
+
},
|
|
307
|
+
],
|
|
308
|
+
outputs: [],
|
|
309
|
+
stateMutability: 'nonpayable',
|
|
310
|
+
name: 'initializeAccount',
|
|
311
|
+
},
|
|
312
|
+
],
|
|
313
|
+
functionName: 'initializeAccount',
|
|
314
|
+
args: [accountFullData],
|
|
315
|
+
});
|
|
316
|
+
return {
|
|
317
|
+
initData: accountInitCallData,
|
|
318
|
+
contract: NEXUS_IMPLEMENTATION_ADDRESS,
|
|
319
|
+
};
|
|
292
320
|
}
|