@rhinestone/sdk 0.0.0-dev-20260204114155
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -0
- 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 +48 -0
- package/dist/src/accounts/index.d.ts.map +1 -0
- package/dist/src/accounts/index.js +643 -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 +27 -0
- package/dist/src/accounts/kernel.d.ts.map +1 -0
- package/dist/src/accounts/kernel.js +281 -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 +33 -0
- package/dist/src/accounts/nexus.d.ts.map +1 -0
- package/dist/src/accounts/nexus.js +455 -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 +9 -0
- package/dist/src/accounts/passport.d.ts.map +1 -0
- package/dist/src/accounts/passport.js +82 -0
- package/dist/src/accounts/safe.d.ts +33 -0
- package/dist/src/accounts/safe.d.ts.map +1 -0
- package/dist/src/accounts/safe.js +349 -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 +190 -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 +25 -0
- package/dist/src/accounts/startale.d.ts.map +1 -0
- package/dist/src/accounts/startale.js +112 -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 +15 -0
- package/dist/src/actions/compact.d.ts.map +1 -0
- package/dist/src/actions/compact.js +213 -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 +23 -0
- package/dist/src/actions/smart-sessions.d.ts.map +1 -0
- package/dist/src/actions/smart-sessions.js +52 -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 +54 -0
- package/dist/src/execution/compact.d.ts +148 -0
- package/dist/src/execution/compact.d.ts.map +1 -0
- package/dist/src/execution/compact.js +120 -0
- package/dist/src/execution/error.d.ts +55 -0
- package/dist/src/execution/error.d.ts.map +1 -0
- package/dist/src/execution/error.js +78 -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 +230 -0
- package/dist/src/execution/permit2.d.ts +143 -0
- package/dist/src/execution/permit2.d.ts.map +1 -0
- package/dist/src/execution/permit2.js +285 -0
- package/dist/src/execution/singleChainOps.d.ts +40 -0
- package/dist/src/execution/singleChainOps.d.ts.map +1 -0
- package/dist/src/execution/singleChainOps.js +46 -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 +87 -0
- package/dist/src/execution/utils.d.ts.map +1 -0
- package/dist/src/execution/utils.js +783 -0
- package/dist/src/index.d.ts +76 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +319 -0
- package/dist/src/modules/abi/smart-session-emissary.d.ts +696 -0
- package/dist/src/modules/abi/smart-session-emissary.d.ts.map +1 -0
- package/dist/src/modules/abi/smart-session-emissary.js +565 -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 +11 -0
- package/dist/src/modules/index.d.ts.map +1 -0
- package/dist/src/modules/index.js +97 -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 +31 -0
- package/dist/src/modules/validators/core.d.ts.map +1 -0
- package/dist/src/modules/validators/core.js +284 -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 +10 -0
- package/dist/src/modules/validators/smart-sessions.d.ts +185 -0
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -0
- package/dist/src/modules/validators/smart-sessions.js +624 -0
- package/dist/src/orchestrator/client.d.ts +22 -0
- package/dist/src/orchestrator/client.d.ts.map +1 -0
- package/dist/src/orchestrator/client.js +360 -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 +242 -0
- package/dist/src/orchestrator/error.d.ts.map +1 -0
- package/dist/src/orchestrator/error.js +283 -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 +58 -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 +116 -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 +154 -0
- package/dist/src/orchestrator/types.d.ts +322 -0
- package/dist/src/orchestrator/types.d.ts.map +1 -0
- package/dist/src/orchestrator/types.js +31 -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 +296 -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 +161 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTransport = createTransport;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const providers_1 = require("./providers");
|
|
6
|
+
function createTransport(chain, provider) {
|
|
7
|
+
if (!provider) {
|
|
8
|
+
return (0, viem_1.http)();
|
|
9
|
+
}
|
|
10
|
+
switch (provider.type) {
|
|
11
|
+
case 'alchemy': {
|
|
12
|
+
const alchemyUrl = (0, providers_1.getAlchemyUrl)(chain.id, provider.apiKey);
|
|
13
|
+
return (0, viem_1.http)(alchemyUrl);
|
|
14
|
+
}
|
|
15
|
+
case 'custom': {
|
|
16
|
+
const customUrl = (0, providers_1.getCustomUrl)(chain.id, provider.urls);
|
|
17
|
+
return (0, viem_1.http)(customUrl);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../../accounts/json-rpc/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chains_1 = require("viem/chains");
|
|
4
|
+
const vitest_1 = require("vitest");
|
|
5
|
+
const index_1 = require("./index");
|
|
6
|
+
(0, vitest_1.describe)('JSON-RPC', () => {
|
|
7
|
+
(0, vitest_1.describe)('createTransport', () => {
|
|
8
|
+
(0, vitest_1.test)('Alchemy', () => {
|
|
9
|
+
const transport = (0, index_1.createTransport)(chains_1.base, {
|
|
10
|
+
type: 'alchemy',
|
|
11
|
+
apiKey: '123',
|
|
12
|
+
});
|
|
13
|
+
(0, vitest_1.expect)(transport).toBeDefined();
|
|
14
|
+
});
|
|
15
|
+
(0, vitest_1.test)('Custom', () => {
|
|
16
|
+
const transport = (0, index_1.createTransport)(chains_1.mainnet, {
|
|
17
|
+
type: 'custom',
|
|
18
|
+
urls: {
|
|
19
|
+
[chains_1.mainnet.id]: 'https://my-rpc.example.com',
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
(0, vitest_1.expect)(transport).toBeDefined();
|
|
23
|
+
});
|
|
24
|
+
(0, vitest_1.test)('Custom throws error when URL not configured for chain', () => {
|
|
25
|
+
(0, vitest_1.expect)(() => (0, index_1.createTransport)(chains_1.mainnet, {
|
|
26
|
+
type: 'custom',
|
|
27
|
+
urls: {
|
|
28
|
+
[chains_1.base.id]: 'https://my-rpc.example.com',
|
|
29
|
+
},
|
|
30
|
+
})).toThrow('No custom provider URL configured for chain 1');
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SupportedChain } from '../../orchestrator';
|
|
2
|
+
declare function getAlchemyUrl(chainId: SupportedChain, apiKey: string): string;
|
|
3
|
+
declare function getCustomUrl(chainId: number, urls: Record<number, string>): string;
|
|
4
|
+
export { getAlchemyUrl, getCustomUrl };
|
|
5
|
+
//# sourceMappingURL=providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../../../accounts/json-rpc/providers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAExD,iBAAS,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAStE;AAED,iBAAS,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAM3E;AAED,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAlchemyUrl = getAlchemyUrl;
|
|
4
|
+
exports.getCustomUrl = getCustomUrl;
|
|
5
|
+
const shared_configs_1 = require("@rhinestone/shared-configs");
|
|
6
|
+
function getAlchemyUrl(chainId, apiKey) {
|
|
7
|
+
const urlTemplate = shared_configs_1.providerRegistry.Alchemy.url_template;
|
|
8
|
+
const chainParam = shared_configs_1.providerRegistry.Alchemy.chain_mapping[chainId];
|
|
9
|
+
if (!chainParam) {
|
|
10
|
+
throw new Error(`Unsupported chain: ${chainId}`);
|
|
11
|
+
}
|
|
12
|
+
return urlTemplate
|
|
13
|
+
.replace('{{chain_param}}', chainParam)
|
|
14
|
+
.replace('\$\{ALCHEMY_API_KEY\}', apiKey);
|
|
15
|
+
}
|
|
16
|
+
function getCustomUrl(chainId, urls) {
|
|
17
|
+
const url = urls[chainId];
|
|
18
|
+
if (!url) {
|
|
19
|
+
throw new Error(`No custom provider URL configured for chain ${chainId}`);
|
|
20
|
+
}
|
|
21
|
+
return url;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.test.d.ts","sourceRoot":"","sources":["../../../../accounts/json-rpc/providers.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chains_1 = require("viem/chains");
|
|
4
|
+
const vitest_1 = require("vitest");
|
|
5
|
+
const providers_1 = require("./providers");
|
|
6
|
+
(0, vitest_1.describe)('Providers', () => {
|
|
7
|
+
(0, vitest_1.describe)('Alchemy', () => {
|
|
8
|
+
(0, vitest_1.test)('Network', () => {
|
|
9
|
+
const mockApiKey = '123';
|
|
10
|
+
(0, vitest_1.expect)((0, providers_1.getAlchemyUrl)(chains_1.arbitrum.id, mockApiKey)).toBe('https://arb-mainnet.g.alchemy.com/v2/123');
|
|
11
|
+
(0, vitest_1.expect)((0, providers_1.getAlchemyUrl)(chains_1.sepolia.id, mockApiKey)).toBe('https://eth-sepolia.g.alchemy.com/v2/123');
|
|
12
|
+
(0, vitest_1.expect)((0, providers_1.getAlchemyUrl)(chains_1.polygon.id, mockApiKey)).toBe('https://polygon-mainnet.g.alchemy.com/v2/123');
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
(0, vitest_1.describe)('Custom', () => {
|
|
16
|
+
(0, vitest_1.test)('Returns URL for configured chain', () => {
|
|
17
|
+
const urls = {
|
|
18
|
+
[chains_1.arbitrum.id]: 'https://my-rpc.example.com/mainnet',
|
|
19
|
+
[chains_1.sepolia.id]: 'https://my-rpc.example.com/sepolia',
|
|
20
|
+
};
|
|
21
|
+
(0, vitest_1.expect)((0, providers_1.getCustomUrl)(chains_1.arbitrum.id, urls)).toBe('https://my-rpc.example.com/mainnet');
|
|
22
|
+
(0, vitest_1.expect)((0, providers_1.getCustomUrl)(chains_1.sepolia.id, urls)).toBe('https://my-rpc.example.com/sepolia');
|
|
23
|
+
});
|
|
24
|
+
(0, vitest_1.test)('Throws error when chain not configured', () => {
|
|
25
|
+
const urls = {
|
|
26
|
+
[chains_1.arbitrum.id]: 'https://my-rpc.example.com/mainnet',
|
|
27
|
+
};
|
|
28
|
+
(0, vitest_1.expect)(() => (0, providers_1.getCustomUrl)(chains_1.sepolia.id, urls)).toThrow('No custom provider URL configured for chain 11155111');
|
|
29
|
+
});
|
|
30
|
+
(0, vitest_1.test)('Accepts HTTP URLs', () => {
|
|
31
|
+
const urls = {
|
|
32
|
+
[chains_1.arbitrum.id]: 'http://localhost:8545',
|
|
33
|
+
};
|
|
34
|
+
(0, vitest_1.expect)((0, providers_1.getCustomUrl)(chains_1.arbitrum.id, urls)).toBe('http://localhost:8545');
|
|
35
|
+
});
|
|
36
|
+
(0, vitest_1.test)('Accepts HTTPS URLs', () => {
|
|
37
|
+
const urls = {
|
|
38
|
+
[chains_1.arbitrum.id]: 'https://my-rpc.example.com',
|
|
39
|
+
};
|
|
40
|
+
(0, vitest_1.expect)((0, providers_1.getCustomUrl)(chains_1.arbitrum.id, urls)).toBe('https://my-rpc.example.com');
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Abi, type Address, type Chain, type Hex, type PublicClient } from 'viem';
|
|
2
|
+
import { type SmartAccount, type SmartAccountImplementation } from 'viem/account-abstraction';
|
|
3
|
+
import { type Module } from '../modules/common';
|
|
4
|
+
import type { OwnerSet, RhinestoneAccountConfig } from '../types';
|
|
5
|
+
import { type ValidatorConfig } from './utils';
|
|
6
|
+
declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
7
|
+
factory: `0x${string}`;
|
|
8
|
+
factoryData: `0x${string}`;
|
|
9
|
+
implementation: `0x${string}`;
|
|
10
|
+
initializationCallData: `0x${string}`;
|
|
11
|
+
salt: `0x${string}`;
|
|
12
|
+
} | null;
|
|
13
|
+
declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
|
|
14
|
+
declare function getEip712Domain(config: RhinestoneAccountConfig, chain: Chain): {
|
|
15
|
+
name: string;
|
|
16
|
+
version: string;
|
|
17
|
+
chainId: number;
|
|
18
|
+
verifyingContract: `0x${string}`;
|
|
19
|
+
salt: "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
20
|
+
};
|
|
21
|
+
declare function getInstallData(module: Module): Hex[];
|
|
22
|
+
declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
|
|
23
|
+
declare function wrapMessageHash(messageHash: Hex, accountAddress: Hex): Hex;
|
|
24
|
+
declare function getSmartAccount(client: PublicClient, address: Address, owners: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
25
|
+
declare function getGuardianSmartAccount(client: PublicClient, address: Address, guardians: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
26
|
+
export { getEip712Domain, getInstallData, getAddress, getDeployArgs, getSmartAccount, getGuardianSmartAccount, packSignature, wrapMessageHash, };
|
|
27
|
+
//# sourceMappingURL=kernel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../../../accounts/kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EACR,KAAK,OAAO,EACZ,KAAK,KAAK,EASV,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;AAE1B,OAAO,KAAK,EAAiB,QAAQ,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAKhF,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAgBhF,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;SAmFrD;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,iBAalD;AAED,iBAAS,eAAe,CAAC,MAAM,EAAE,uBAAuB,EAAE,KAAK,EAAE,KAAK;;;;;;EAarE;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,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,eAAe,EACf,cAAc,EACd,UAAU,EACV,aAAa,EACb,eAAe,EACf,uBAAuB,EACvB,aAAa,EACb,eAAe,GAChB,CAAA"}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEip712Domain = getEip712Domain;
|
|
4
|
+
exports.getInstallData = getInstallData;
|
|
5
|
+
exports.getAddress = getAddress;
|
|
6
|
+
exports.getDeployArgs = getDeployArgs;
|
|
7
|
+
exports.getSmartAccount = getSmartAccount;
|
|
8
|
+
exports.getGuardianSmartAccount = getGuardianSmartAccount;
|
|
9
|
+
exports.packSignature = packSignature;
|
|
10
|
+
exports.wrapMessageHash = wrapMessageHash;
|
|
11
|
+
const viem_1 = require("viem");
|
|
12
|
+
const account_abstraction_1 = require("viem/account-abstraction");
|
|
13
|
+
const modules_1 = require("../modules");
|
|
14
|
+
const common_1 = require("../modules/common");
|
|
15
|
+
const validators_1 = require("../modules/validators");
|
|
16
|
+
const error_1 = require("./error");
|
|
17
|
+
const utils_1 = require("./utils");
|
|
18
|
+
const KERNEL_META_FACTORY_ADDRESS = '0xd703aae79538628d27099b8c4f621be4ccd142d5';
|
|
19
|
+
const KERNEL_IMPLEMENTATION_ADDRESS = '0xd6CEDDe84be40893d153Be9d467CD6aD37875b28';
|
|
20
|
+
const KERNEL_FACTORY_ADDRESS = '0x2577507b78c2008Ff367261CB6285d44ba5eF2E9';
|
|
21
|
+
const KERNEL_BYTECODE = '0x603d3d8160223d3973d6cedde84be40893d153be9d467cd6ad37875b2860095155f3363d3d373d3d363d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc545af43d6000803e6038573d6000fd5b3d6000f3';
|
|
22
|
+
const KERNEL_VERSION = '0.3.3';
|
|
23
|
+
function getDeployArgs(config) {
|
|
24
|
+
if (config.initData) {
|
|
25
|
+
if (!('factory' in config.initData)) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const factoryData = (0, viem_1.decodeFunctionData)({
|
|
29
|
+
abi: (0, viem_1.parseAbi)([
|
|
30
|
+
'function deployWithFactory(address factory,bytes createData,bytes32 salt)',
|
|
31
|
+
]),
|
|
32
|
+
data: config.initData.factoryData,
|
|
33
|
+
});
|
|
34
|
+
if (factoryData.functionName !== 'deployWithFactory') {
|
|
35
|
+
throw new error_1.AccountConfigurationNotSupportedError('Invalid factory data', 'kernel');
|
|
36
|
+
}
|
|
37
|
+
const factory = factoryData.args[0];
|
|
38
|
+
const createData = factoryData.args[1];
|
|
39
|
+
const salt = factoryData.args[2];
|
|
40
|
+
const implementation = factory === KERNEL_FACTORY_ADDRESS
|
|
41
|
+
? KERNEL_IMPLEMENTATION_ADDRESS
|
|
42
|
+
: viem_1.zeroAddress;
|
|
43
|
+
if (implementation === viem_1.zeroAddress) {
|
|
44
|
+
throw new error_1.AccountConfigurationNotSupportedError('Unsupported Kernel implementation', 'kernel');
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
factory: config.initData.factory,
|
|
48
|
+
factoryData: config.initData.factoryData,
|
|
49
|
+
implementation,
|
|
50
|
+
initializationCallData: createData,
|
|
51
|
+
salt,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const account = config.account;
|
|
55
|
+
const salt = account?.salt ?? viem_1.zeroHash;
|
|
56
|
+
const moduleSetup = (0, modules_1.getSetup)(config);
|
|
57
|
+
const rootValidator = (0, viem_1.concat)(['0x01', moduleSetup.validators[0].address]);
|
|
58
|
+
const hook = viem_1.zeroAddress;
|
|
59
|
+
const validatorData = moduleSetup.validators[0].initData;
|
|
60
|
+
const hookData = '0x';
|
|
61
|
+
// Install modules via init config
|
|
62
|
+
const spareValidators = moduleSetup.validators.slice(1);
|
|
63
|
+
const initConfig = [];
|
|
64
|
+
for (const module of spareValidators) {
|
|
65
|
+
initConfig.push(...getInstallData(module));
|
|
66
|
+
}
|
|
67
|
+
for (const module of moduleSetup.executors) {
|
|
68
|
+
initConfig.push(...getInstallData(module));
|
|
69
|
+
}
|
|
70
|
+
for (const module of moduleSetup.fallbacks) {
|
|
71
|
+
initConfig.push(...getInstallData(module));
|
|
72
|
+
}
|
|
73
|
+
for (const module of moduleSetup.hooks) {
|
|
74
|
+
initConfig.push(...getInstallData(module));
|
|
75
|
+
}
|
|
76
|
+
const initializationCallData = (0, viem_1.encodeFunctionData)({
|
|
77
|
+
abi: (0, viem_1.parseAbi)(['function initialize(bytes21,address,bytes,bytes,bytes[])']),
|
|
78
|
+
functionName: 'initialize',
|
|
79
|
+
args: [rootValidator, hook, validatorData, hookData, initConfig],
|
|
80
|
+
});
|
|
81
|
+
const factoryData = (0, viem_1.encodeFunctionData)({
|
|
82
|
+
abi: (0, viem_1.parseAbi)(['function deployWithFactory(address,bytes,bytes32)']),
|
|
83
|
+
functionName: 'deployWithFactory',
|
|
84
|
+
args: [KERNEL_FACTORY_ADDRESS, initializationCallData, salt],
|
|
85
|
+
});
|
|
86
|
+
return {
|
|
87
|
+
factory: KERNEL_META_FACTORY_ADDRESS,
|
|
88
|
+
factoryData,
|
|
89
|
+
salt,
|
|
90
|
+
implementation: KERNEL_IMPLEMENTATION_ADDRESS,
|
|
91
|
+
initializationCallData,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function getAddress(config) {
|
|
95
|
+
const deployArgs = getDeployArgs(config);
|
|
96
|
+
if (!deployArgs) {
|
|
97
|
+
throw new Error('Cannot derive address: deploy args not available');
|
|
98
|
+
}
|
|
99
|
+
const { salt, initializationCallData } = deployArgs;
|
|
100
|
+
const actualSalt = (0, viem_1.keccak256)((0, viem_1.concat)([initializationCallData, salt]));
|
|
101
|
+
return (0, viem_1.getContractAddress)({
|
|
102
|
+
from: KERNEL_FACTORY_ADDRESS,
|
|
103
|
+
opcode: 'CREATE2',
|
|
104
|
+
bytecode: KERNEL_BYTECODE,
|
|
105
|
+
salt: actualSalt,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function getEip712Domain(config, chain) {
|
|
109
|
+
if (config.initData) {
|
|
110
|
+
throw new error_1.Eip712DomainNotAvailableError('Existing Kernel accounts are not yet supported');
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
name: 'Kernel',
|
|
114
|
+
version: KERNEL_VERSION,
|
|
115
|
+
chainId: chain.id,
|
|
116
|
+
verifyingContract: getAddress(config),
|
|
117
|
+
salt: viem_1.zeroHash,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function getInstallData(module) {
|
|
121
|
+
const HOOK_INSTALLED_ADDRESS = '0x0000000000000000000000000000000000000001';
|
|
122
|
+
switch (module.type) {
|
|
123
|
+
case common_1.MODULE_TYPE_ID_VALIDATOR: {
|
|
124
|
+
const data = (0, viem_1.encodeAbiParameters)([{ type: 'bytes' }, { type: 'bytes' }, { type: 'bytes' }], [module.initData, '0x', '0x']);
|
|
125
|
+
const initData = (0, viem_1.concat)([HOOK_INSTALLED_ADDRESS, data]);
|
|
126
|
+
const validatorId = (0, viem_1.concat)(['0x01', module.address]);
|
|
127
|
+
return [
|
|
128
|
+
(0, viem_1.encodeFunctionData)({
|
|
129
|
+
abi: (0, viem_1.parseAbi)(['function installModule(uint256,address,bytes)']),
|
|
130
|
+
functionName: 'installModule',
|
|
131
|
+
args: [module.type, module.address, initData],
|
|
132
|
+
}),
|
|
133
|
+
(0, viem_1.encodeFunctionData)({
|
|
134
|
+
abi: (0, viem_1.parseAbi)(['function grantAccess(bytes21,bytes4,bool)']),
|
|
135
|
+
functionName: 'grantAccess',
|
|
136
|
+
args: [validatorId, '0xe9ae5c53', true],
|
|
137
|
+
}),
|
|
138
|
+
];
|
|
139
|
+
}
|
|
140
|
+
case common_1.MODULE_TYPE_ID_EXECUTOR: {
|
|
141
|
+
const data = (0, viem_1.encodeAbiParameters)([{ type: 'bytes' }, { type: 'bytes' }], [module.initData, '0x']);
|
|
142
|
+
const initData = (0, viem_1.concat)([viem_1.zeroAddress, data]);
|
|
143
|
+
return [
|
|
144
|
+
(0, viem_1.encodeFunctionData)({
|
|
145
|
+
abi: (0, viem_1.parseAbi)(['function installModule(uint256,address,bytes)']),
|
|
146
|
+
functionName: 'installModule',
|
|
147
|
+
args: [module.type, module.address, initData],
|
|
148
|
+
}),
|
|
149
|
+
];
|
|
150
|
+
}
|
|
151
|
+
case common_1.MODULE_TYPE_ID_FALLBACK: {
|
|
152
|
+
const [selector, flags, selectorData] = (0, viem_1.decodeAbiParameters)([
|
|
153
|
+
{ name: 'selector', type: 'bytes4' },
|
|
154
|
+
{ name: 'flags', type: 'bytes1' },
|
|
155
|
+
{ name: 'data', type: 'bytes' },
|
|
156
|
+
], module.initData);
|
|
157
|
+
const data = (0, viem_1.encodeAbiParameters)([{ type: 'bytes' }, { type: 'bytes' }], [(0, viem_1.concat)([flags, selectorData]), '0x']);
|
|
158
|
+
const initData = (0, viem_1.concat)([selector, HOOK_INSTALLED_ADDRESS, data]);
|
|
159
|
+
return [
|
|
160
|
+
(0, viem_1.encodeFunctionData)({
|
|
161
|
+
abi: (0, viem_1.parseAbi)(['function installModule(uint256,address,bytes)']),
|
|
162
|
+
functionName: 'installModule',
|
|
163
|
+
args: [module.type, module.address, initData],
|
|
164
|
+
}),
|
|
165
|
+
];
|
|
166
|
+
}
|
|
167
|
+
case common_1.MODULE_TYPE_ID_HOOK: {
|
|
168
|
+
return [
|
|
169
|
+
(0, viem_1.encodeFunctionData)({
|
|
170
|
+
abi: (0, viem_1.parseAbi)(['function installModule(uint256,address,bytes)']),
|
|
171
|
+
functionName: 'installModule',
|
|
172
|
+
args: [module.type, module.address, module.initData],
|
|
173
|
+
}),
|
|
174
|
+
];
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
async function packSignature(signature, validator, transformSignature = (signature) => signature) {
|
|
179
|
+
const vId = validator.isRoot ? '0x00' : (0, viem_1.concat)(['0x01', validator.address]);
|
|
180
|
+
const magicValueSigReplayable = (0, viem_1.keccak256)((0, viem_1.toHex)('kernel.replayable.signature'));
|
|
181
|
+
const packedSig = (0, viem_1.concat)([
|
|
182
|
+
vId,
|
|
183
|
+
magicValueSigReplayable,
|
|
184
|
+
transformSignature(signature),
|
|
185
|
+
]);
|
|
186
|
+
return packedSig;
|
|
187
|
+
}
|
|
188
|
+
function wrapMessageHash(messageHash, accountAddress) {
|
|
189
|
+
const _domainSeparator = (0, viem_1.domainSeparator)({
|
|
190
|
+
domain: {
|
|
191
|
+
name: 'Kernel',
|
|
192
|
+
version: KERNEL_VERSION,
|
|
193
|
+
chainId: 0,
|
|
194
|
+
verifyingContract: accountAddress,
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
const kernelTypeHash = (0, viem_1.keccak256)((0, viem_1.stringToHex)('Kernel(bytes32 hash)'));
|
|
198
|
+
const wrappedMessageHash = (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: 'bytes32' }, { type: 'bytes32' }], [kernelTypeHash, messageHash]));
|
|
199
|
+
const digest = (0, viem_1.keccak256)((0, viem_1.concatHex)(['0x1901', _domainSeparator, wrappedMessageHash]));
|
|
200
|
+
return digest;
|
|
201
|
+
}
|
|
202
|
+
async function getSmartAccount(client, address, owners, validatorAddress, sign) {
|
|
203
|
+
return getBaseSmartAccount(address, client, validatorAddress, 'root', async () => {
|
|
204
|
+
return (0, validators_1.getMockSignature)(owners);
|
|
205
|
+
}, sign);
|
|
206
|
+
}
|
|
207
|
+
async function getGuardianSmartAccount(client, address, guardians, validatorAddress, sign) {
|
|
208
|
+
return await getBaseSmartAccount(address, client, validatorAddress, 'validator', async () => {
|
|
209
|
+
return (0, validators_1.getMockSignature)(guardians);
|
|
210
|
+
}, async (hash) => {
|
|
211
|
+
return await sign(hash);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
async function getBaseSmartAccount(address, client, validatorAddress, validatorType, getStubSignature, signUserOperation) {
|
|
215
|
+
return await (0, account_abstraction_1.toSmartAccount)({
|
|
216
|
+
client,
|
|
217
|
+
entryPoint: {
|
|
218
|
+
abi: account_abstraction_1.entryPoint07Abi,
|
|
219
|
+
address: account_abstraction_1.entryPoint07Address,
|
|
220
|
+
version: '0.7',
|
|
221
|
+
},
|
|
222
|
+
async decodeCalls() {
|
|
223
|
+
throw new Error('Not implemented');
|
|
224
|
+
},
|
|
225
|
+
async encodeCalls(calls) {
|
|
226
|
+
return (0, utils_1.encode7579Calls)({
|
|
227
|
+
mode: {
|
|
228
|
+
type: calls.length > 1 ? 'batchcall' : 'call',
|
|
229
|
+
revertOnError: false,
|
|
230
|
+
selector: '0x',
|
|
231
|
+
context: '0x',
|
|
232
|
+
},
|
|
233
|
+
callData: calls,
|
|
234
|
+
});
|
|
235
|
+
},
|
|
236
|
+
async getAddress() {
|
|
237
|
+
return address;
|
|
238
|
+
},
|
|
239
|
+
async getFactoryArgs() {
|
|
240
|
+
return {};
|
|
241
|
+
},
|
|
242
|
+
async getNonce() {
|
|
243
|
+
// Default mode
|
|
244
|
+
const mode = '0x00';
|
|
245
|
+
const type = validatorType === 'root' ? '0x00' : '0x01';
|
|
246
|
+
const identifier = validatorAddress;
|
|
247
|
+
const nonceKey = '0x0000';
|
|
248
|
+
const key = (0, viem_1.concat)([mode, type, identifier, nonceKey]);
|
|
249
|
+
return (0, utils_1.getAccountNonce)(client, {
|
|
250
|
+
address,
|
|
251
|
+
entryPointAddress: account_abstraction_1.entryPoint07Address,
|
|
252
|
+
key: BigInt(key),
|
|
253
|
+
});
|
|
254
|
+
},
|
|
255
|
+
async getStubSignature() {
|
|
256
|
+
return getStubSignature();
|
|
257
|
+
},
|
|
258
|
+
async signMessage() {
|
|
259
|
+
throw new Error('Not implemented');
|
|
260
|
+
},
|
|
261
|
+
async signTypedData() {
|
|
262
|
+
throw new Error('Not implemented');
|
|
263
|
+
},
|
|
264
|
+
async signUserOperation(parameters) {
|
|
265
|
+
const { chainId = client.chain?.id, ...userOperation } = parameters;
|
|
266
|
+
if (!chainId)
|
|
267
|
+
throw new Error('Chain id not found');
|
|
268
|
+
const hash = (0, account_abstraction_1.getUserOperationHash)({
|
|
269
|
+
userOperation: {
|
|
270
|
+
...userOperation,
|
|
271
|
+
sender: userOperation.sender ?? (await this.getAddress()),
|
|
272
|
+
signature: '0x',
|
|
273
|
+
},
|
|
274
|
+
entryPointAddress: account_abstraction_1.entryPoint07Address,
|
|
275
|
+
entryPointVersion: '0.7',
|
|
276
|
+
chainId: chainId,
|
|
277
|
+
});
|
|
278
|
+
return await signUserOperation(hash);
|
|
279
|
+
},
|
|
280
|
+
});
|
|
281
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kernel.test.d.ts","sourceRoot":"","sources":["../../../accounts/kernel.test.ts"],"names":[],"mappings":""}
|
|
@@ -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
|
+
});
|