@rhinestone/sdk 1.4.2 → 2.0.0-beta.0
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 +89 -1
- package/dist/src/accounts/error.d.ts +1 -1
- package/dist/src/accounts/error.js +1 -19
- package/dist/src/accounts/index.d.ts +5 -5
- package/dist/src/accounts/index.js +121 -157
- package/dist/src/accounts/json-rpc/index.d.ts +1 -1
- package/dist/src/accounts/json-rpc/index.js +8 -10
- package/dist/src/accounts/json-rpc/providers.d.ts +1 -1
- package/dist/src/accounts/json-rpc/providers.js +4 -7
- package/dist/src/accounts/kernel.d.ts +3 -3
- package/dist/src/accounts/kernel.js +66 -75
- package/dist/src/accounts/nexus.d.ts +3 -3
- package/dist/src/accounts/nexus.js +62 -73
- package/dist/src/accounts/passport.d.ts +3 -3
- package/dist/src/accounts/passport.js +9 -13
- package/dist/src/accounts/safe.d.ts +3 -3
- package/dist/src/accounts/safe.js +54 -63
- package/dist/src/accounts/signing/common.d.ts +10 -4
- package/dist/src/accounts/signing/common.d.ts.map +1 -1
- package/dist/src/accounts/signing/common.js +30 -36
- package/dist/src/accounts/signing/message.d.ts +2 -2
- package/dist/src/accounts/signing/message.js +10 -12
- package/dist/src/accounts/signing/passkeys.js +11 -17
- package/dist/src/accounts/signing/typedData.d.ts +1 -1
- package/dist/src/accounts/signing/typedData.js +6 -8
- package/dist/src/accounts/startale.d.ts +3 -3
- package/dist/src/accounts/startale.js +37 -47
- package/dist/src/accounts/utils.d.ts +2 -2
- package/dist/src/accounts/utils.js +22 -28
- package/dist/src/accounts/walletClient.js +4 -8
- package/dist/src/actions/compact.d.ts +1 -1
- package/dist/src/actions/compact.js +22 -35
- package/dist/src/actions/deployment.d.ts +1 -1
- package/dist/src/actions/deployment.js +11 -13
- package/dist/src/actions/ecdsa.d.ts +1 -1
- package/dist/src/actions/ecdsa.js +14 -20
- package/dist/src/actions/index.d.ts +2 -2
- package/dist/src/actions/index.js +6 -10
- package/dist/src/actions/mfa.d.ts +1 -1
- package/dist/src/actions/mfa.js +18 -24
- package/dist/src/actions/passkeys.d.ts +2 -2
- package/dist/src/actions/passkeys.js +14 -20
- package/dist/src/actions/recovery.d.ts +1 -1
- package/dist/src/actions/recovery.js +25 -29
- package/dist/src/actions/smart-sessions.d.ts +1 -1
- package/dist/src/actions/smart-sessions.js +8 -12
- package/dist/src/auth/provider.d.ts +7 -0
- package/dist/src/auth/provider.d.ts.map +1 -0
- package/dist/src/auth/provider.js +38 -0
- package/dist/src/errors/index.d.ts +3 -3
- package/dist/src/errors/index.js +10 -54
- package/dist/src/execution/compact.d.ts +3 -3
- package/dist/src/execution/compact.js +10 -18
- package/dist/src/execution/error.js +1 -11
- package/dist/src/execution/index.d.ts +9 -8
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +54 -67
- package/dist/src/execution/permit2.d.ts +5 -5
- package/dist/src/execution/permit2.js +8 -13
- package/dist/src/execution/singleChainOps.d.ts +2 -2
- package/dist/src/execution/singleChainOps.js +1 -3
- package/dist/src/execution/types.d.ts +1 -1
- package/dist/src/execution/types.js +1 -2
- package/dist/src/execution/utils.d.ts +10 -6
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +159 -162
- package/dist/src/index.d.ts +10 -10
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +57 -67
- package/dist/src/jwt-server/digest.d.ts +11 -0
- package/dist/src/jwt-server/digest.d.ts.map +1 -0
- package/dist/src/jwt-server/digest.js +19 -0
- package/dist/src/jwt-server/express.d.ts +16 -0
- package/dist/src/jwt-server/express.d.ts.map +1 -0
- package/dist/src/jwt-server/express.js +23 -0
- package/dist/src/jwt-server/handlers.d.ts +10 -0
- package/dist/src/jwt-server/handlers.d.ts.map +1 -0
- package/dist/src/jwt-server/handlers.js +37 -0
- package/dist/src/jwt-server/index.d.ts +8 -0
- package/dist/src/jwt-server/index.d.ts.map +1 -0
- package/dist/src/jwt-server/index.js +7 -0
- package/dist/src/jwt-server/jcs.d.ts +12 -0
- package/dist/src/jwt-server/jcs.d.ts.map +1 -0
- package/dist/src/jwt-server/jcs.js +57 -0
- package/dist/src/jwt-server/signer.d.ts +18 -0
- package/dist/src/jwt-server/signer.d.ts.map +1 -0
- package/dist/src/jwt-server/signer.js +68 -0
- package/dist/src/jwt-server/sponsorship.d.ts +19 -0
- package/dist/src/jwt-server/sponsorship.d.ts.map +1 -0
- package/dist/src/jwt-server/sponsorship.js +51 -0
- package/dist/src/jwt-server/web.d.ts +4 -0
- package/dist/src/jwt-server/web.d.ts.map +1 -0
- package/dist/src/jwt-server/web.js +23 -0
- package/dist/src/modules/abi/smart-session-emissary.js +1 -3
- package/dist/src/modules/abi/smart-sessions.js +1 -4
- package/dist/src/modules/chain-abstraction.js +1 -5
- package/dist/src/modules/common.d.ts +1 -1
- package/dist/src/modules/common.js +1 -13
- package/dist/src/modules/index.d.ts +5 -5
- package/dist/src/modules/index.js +35 -50
- package/dist/src/modules/legacy.d.ts +2 -2
- package/dist/src/modules/legacy.js +11 -14
- package/dist/src/modules/read.d.ts +1 -1
- package/dist/src/modules/read.js +11 -15
- package/dist/src/modules/validators/core.d.ts +2 -2
- package/dist/src/modules/validators/core.js +26 -44
- package/dist/src/modules/validators/index.d.ts +2 -2
- package/dist/src/modules/validators/index.js +3 -19
- package/dist/src/modules/validators/policies/claim/permit2.d.ts +1 -1
- package/dist/src/modules/validators/policies/claim/permit2.js +39 -44
- package/dist/src/modules/validators/policies/claim/types.js +11 -14
- package/dist/src/modules/validators/smart-sessions.d.ts +4 -4
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
- package/dist/src/modules/validators/smart-sessions.js +77 -97
- package/dist/src/orchestrator/client.d.ts +10 -5
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +73 -66
- package/dist/src/orchestrator/consts.d.ts +1 -1
- package/dist/src/orchestrator/consts.d.ts.map +1 -1
- package/dist/src/orchestrator/consts.js +2 -8
- package/dist/src/orchestrator/error.js +1 -33
- package/dist/src/orchestrator/index.d.ts +8 -7
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +8 -57
- package/dist/src/orchestrator/registry.d.ts +2 -2
- package/dist/src/orchestrator/registry.js +19 -33
- package/dist/src/orchestrator/types.d.ts +5 -1
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/orchestrator/types.js +1 -17
- package/dist/src/orchestrator/utils.js +1 -3
- package/dist/src/types.d.ts +29 -5
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +1 -2
- package/dist/src/utils/index.d.ts +2 -2
- package/dist/src/utils/index.js +9 -15
- package/package.json +29 -98
- package/dist/src/accounts/index.test.d.ts +0 -2
- package/dist/src/accounts/index.test.d.ts.map +0 -1
- package/dist/src/accounts/index.test.js +0 -33
- package/dist/src/accounts/json-rpc/index.test.d.ts +0 -2
- package/dist/src/accounts/json-rpc/index.test.d.ts.map +0 -1
- package/dist/src/accounts/json-rpc/index.test.js +0 -35
- package/dist/src/accounts/json-rpc/providers.test.d.ts +0 -2
- package/dist/src/accounts/json-rpc/providers.test.d.ts.map +0 -1
- package/dist/src/accounts/json-rpc/providers.test.js +0 -43
- package/dist/src/accounts/kernel.test.d.ts +0 -2
- package/dist/src/accounts/kernel.test.d.ts.map +0 -1
- package/dist/src/accounts/kernel.test.js +0 -132
- package/dist/src/accounts/nexus.test.d.ts +0 -2
- package/dist/src/accounts/nexus.test.d.ts.map +0 -1
- package/dist/src/accounts/nexus.test.js +0 -118
- package/dist/src/accounts/safe.test.d.ts +0 -2
- package/dist/src/accounts/safe.test.d.ts.map +0 -1
- package/dist/src/accounts/safe.test.js +0 -168
- package/dist/src/accounts/signing/passkeys.test.d.ts +0 -2
- package/dist/src/accounts/signing/passkeys.test.d.ts.map +0 -1
- package/dist/src/accounts/signing/passkeys.test.js +0 -88
- package/dist/src/accounts/startale.test.d.ts +0 -2
- package/dist/src/accounts/startale.test.d.ts.map +0 -1
- package/dist/src/accounts/startale.test.js +0 -189
- package/dist/src/accounts/utils.test.d.ts +0 -2
- package/dist/src/accounts/utils.test.d.ts.map +0 -1
- package/dist/src/accounts/utils.test.js +0 -49
- package/dist/src/actions/ecdsa.test.d.ts +0 -2
- package/dist/src/actions/ecdsa.test.d.ts.map +0 -1
- package/dist/src/actions/ecdsa.test.js +0 -99
- package/dist/src/actions/passkeys.test.d.ts +0 -2
- package/dist/src/actions/passkeys.test.d.ts.map +0 -1
- package/dist/src/actions/passkeys.test.js +0 -54
- package/dist/src/actions/recovery.test.d.ts +0 -2
- package/dist/src/actions/recovery.test.d.ts.map +0 -1
- package/dist/src/actions/recovery.test.js +0 -168
- package/dist/src/execution/signing.test.d.ts +0 -2
- package/dist/src/execution/signing.test.d.ts.map +0 -1
- package/dist/src/execution/signing.test.js +0 -465
- package/dist/src/execution/utils.test.d.ts +0 -2
- package/dist/src/execution/utils.test.d.ts.map +0 -1
- package/dist/src/execution/utils.test.js +0 -388
- package/dist/src/modules/index.test.d.ts +0 -2
- package/dist/src/modules/index.test.d.ts.map +0 -1
- package/dist/src/modules/index.test.js +0 -81
- package/dist/src/modules/validators/core.test.d.ts +0 -2
- package/dist/src/modules/validators/core.test.d.ts.map +0 -1
- package/dist/src/modules/validators/core.test.js +0 -101
- package/dist/src/modules/validators/policies/claim/permit2.test.d.ts +0 -2
- package/dist/src/modules/validators/policies/claim/permit2.test.d.ts.map +0 -1
- package/dist/src/modules/validators/policies/claim/permit2.test.js +0 -519
- package/dist/src/modules/validators/smart-sessions.test.d.ts +0 -2
- package/dist/src/modules/validators/smart-sessions.test.d.ts.map +0 -1
- package/dist/src/modules/validators/smart-sessions.test.js +0 -311
- package/dist/src/orchestrator/registry.test.d.ts +0 -2
- package/dist/src/orchestrator/registry.test.d.ts.map +0 -1
- package/dist/src/orchestrator/registry.test.js +0 -154
- package/dist/src/utils/index.test.d.ts +0 -2
- package/dist/src/utils/index.test.d.ts.map +0 -1
- package/dist/src/utils/index.test.js +0 -42
- package/dist/test/consts.d.ts +0 -10
- package/dist/test/consts.d.ts.map +0 -1
- package/dist/test/consts.js +0 -22
- package/dist/test/utils/utils.d.ts +0 -5
- package/dist/test/utils/utils.d.ts.map +0 -1
- package/dist/test/utils/utils.js +0 -20
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAlchemyUrl = getAlchemyUrl;
|
|
4
|
-
exports.getCustomUrl = getCustomUrl;
|
|
5
|
-
const shared_configs_1 = require("@rhinestone/shared-configs");
|
|
1
|
+
import { providerRegistry as providers } from '@rhinestone/shared-configs';
|
|
6
2
|
function getAlchemyUrl(chainId, apiKey) {
|
|
7
|
-
const urlTemplate =
|
|
8
|
-
const chainParam =
|
|
3
|
+
const urlTemplate = providers.Alchemy.url_template;
|
|
4
|
+
const chainParam = providers.Alchemy.chain_mapping[chainId];
|
|
9
5
|
if (!chainParam) {
|
|
10
6
|
throw new Error(`Unsupported chain: ${chainId}`);
|
|
11
7
|
}
|
|
@@ -16,3 +12,4 @@ function getAlchemyUrl(chainId, apiKey) {
|
|
|
16
12
|
function getCustomUrl(chainId, urls) {
|
|
17
13
|
return urls[chainId];
|
|
18
14
|
}
|
|
15
|
+
export { getAlchemyUrl, getCustomUrl };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type Abi, type Address, type Chain, type Hex, type PublicClient } from 'viem';
|
|
2
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';
|
|
3
|
+
import { type Module } from '../modules/common.js';
|
|
4
|
+
import type { OwnerSet, RhinestoneAccountConfig } from '../types.js';
|
|
5
|
+
import { type ValidatorConfig } from './utils.js';
|
|
6
6
|
declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
7
7
|
factory: `0x${string}`;
|
|
8
8
|
factoryData: `0x${string}`;
|
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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");
|
|
1
|
+
import { concat, concatHex, decodeAbiParameters, decodeFunctionData, domainSeparator, encodeAbiParameters, encodeFunctionData, getContractAddress, keccak256, parseAbi, stringToHex, toHex, zeroAddress, zeroHash, } from 'viem';
|
|
2
|
+
import { entryPoint07Abi, entryPoint07Address, getUserOperationHash, toSmartAccount, } from 'viem/account-abstraction';
|
|
3
|
+
import { getSetup as getModuleSetup } from '../modules/index.js';
|
|
4
|
+
import { MODULE_TYPE_ID_EXECUTOR, MODULE_TYPE_ID_FALLBACK, MODULE_TYPE_ID_HOOK, MODULE_TYPE_ID_VALIDATOR, } from '../modules/common.js';
|
|
5
|
+
import { getMockSignature } from '../modules/validators/index.js';
|
|
6
|
+
import { AccountConfigurationNotSupportedError, Eip712DomainNotAvailableError, } from './error.js';
|
|
7
|
+
import { encode7579Calls, getAccountNonce } from './utils.js';
|
|
18
8
|
const KERNEL_META_FACTORY_ADDRESS = '0xd703aae79538628d27099b8c4f621be4ccd142d5';
|
|
19
9
|
const KERNEL_IMPLEMENTATION_ADDRESS = '0xd6cedde84be40893d153be9d467cd6ad37875b28';
|
|
20
10
|
const KERNEL_FACTORY_ADDRESS = '0x2577507b78c2008ff367261cb6285d44ba5ef2e9';
|
|
@@ -25,23 +15,23 @@ function getDeployArgs(config) {
|
|
|
25
15
|
if (!('factory' in config.initData)) {
|
|
26
16
|
return null;
|
|
27
17
|
}
|
|
28
|
-
const factoryData =
|
|
29
|
-
abi:
|
|
18
|
+
const factoryData = decodeFunctionData({
|
|
19
|
+
abi: parseAbi([
|
|
30
20
|
'function deployWithFactory(address factory,bytes createData,bytes32 salt)',
|
|
31
21
|
]),
|
|
32
22
|
data: config.initData.factoryData,
|
|
33
23
|
});
|
|
34
24
|
if (factoryData.functionName !== 'deployWithFactory') {
|
|
35
|
-
throw new
|
|
25
|
+
throw new AccountConfigurationNotSupportedError('Invalid factory data', 'kernel');
|
|
36
26
|
}
|
|
37
27
|
const factory = factoryData.args[0];
|
|
38
28
|
const createData = factoryData.args[1];
|
|
39
29
|
const salt = factoryData.args[2];
|
|
40
30
|
const implementation = factory.toLowerCase() === KERNEL_FACTORY_ADDRESS
|
|
41
31
|
? KERNEL_IMPLEMENTATION_ADDRESS
|
|
42
|
-
:
|
|
43
|
-
if (implementation ===
|
|
44
|
-
throw new
|
|
32
|
+
: zeroAddress;
|
|
33
|
+
if (implementation === zeroAddress) {
|
|
34
|
+
throw new AccountConfigurationNotSupportedError('Unsupported Kernel implementation', 'kernel');
|
|
45
35
|
}
|
|
46
36
|
return {
|
|
47
37
|
factory: config.initData.factory,
|
|
@@ -52,10 +42,10 @@ function getDeployArgs(config) {
|
|
|
52
42
|
};
|
|
53
43
|
}
|
|
54
44
|
const account = config.account;
|
|
55
|
-
const salt = account?.salt ??
|
|
56
|
-
const moduleSetup = (
|
|
57
|
-
const rootValidator =
|
|
58
|
-
const hook =
|
|
45
|
+
const salt = account?.salt ?? zeroHash;
|
|
46
|
+
const moduleSetup = getModuleSetup(config);
|
|
47
|
+
const rootValidator = concat(['0x01', moduleSetup.validators[0].address]);
|
|
48
|
+
const hook = zeroAddress;
|
|
59
49
|
const validatorData = moduleSetup.validators[0].initData;
|
|
60
50
|
const hookData = '0x';
|
|
61
51
|
// Install modules via init config
|
|
@@ -73,13 +63,13 @@ function getDeployArgs(config) {
|
|
|
73
63
|
for (const module of moduleSetup.hooks) {
|
|
74
64
|
initConfig.push(...getInstallData(module));
|
|
75
65
|
}
|
|
76
|
-
const initializationCallData =
|
|
77
|
-
abi:
|
|
66
|
+
const initializationCallData = encodeFunctionData({
|
|
67
|
+
abi: parseAbi(['function initialize(bytes21,address,bytes,bytes,bytes[])']),
|
|
78
68
|
functionName: 'initialize',
|
|
79
69
|
args: [rootValidator, hook, validatorData, hookData, initConfig],
|
|
80
70
|
});
|
|
81
|
-
const factoryData =
|
|
82
|
-
abi:
|
|
71
|
+
const factoryData = encodeFunctionData({
|
|
72
|
+
abi: parseAbi(['function deployWithFactory(address,bytes,bytes32)']),
|
|
83
73
|
functionName: 'deployWithFactory',
|
|
84
74
|
args: [KERNEL_FACTORY_ADDRESS, initializationCallData, salt],
|
|
85
75
|
});
|
|
@@ -97,8 +87,8 @@ function getAddress(config) {
|
|
|
97
87
|
throw new Error('Cannot derive address: deploy args not available');
|
|
98
88
|
}
|
|
99
89
|
const { salt, initializationCallData } = deployArgs;
|
|
100
|
-
const actualSalt =
|
|
101
|
-
return
|
|
90
|
+
const actualSalt = keccak256(concat([initializationCallData, salt]));
|
|
91
|
+
return getContractAddress({
|
|
102
92
|
from: KERNEL_FACTORY_ADDRESS,
|
|
103
93
|
opcode: 'CREATE2',
|
|
104
94
|
bytecode: KERNEL_BYTECODE,
|
|
@@ -107,67 +97,67 @@ function getAddress(config) {
|
|
|
107
97
|
}
|
|
108
98
|
function getEip712Domain(config, chain) {
|
|
109
99
|
if (config.initData) {
|
|
110
|
-
throw new
|
|
100
|
+
throw new Eip712DomainNotAvailableError('Existing Kernel accounts are not yet supported');
|
|
111
101
|
}
|
|
112
102
|
return {
|
|
113
103
|
name: 'Kernel',
|
|
114
104
|
version: KERNEL_VERSION,
|
|
115
105
|
chainId: chain.id,
|
|
116
106
|
verifyingContract: getAddress(config),
|
|
117
|
-
salt:
|
|
107
|
+
salt: zeroHash,
|
|
118
108
|
};
|
|
119
109
|
}
|
|
120
110
|
function getInstallData(module) {
|
|
121
111
|
const HOOK_INSTALLED_ADDRESS = '0x0000000000000000000000000000000000000001';
|
|
122
112
|
switch (module.type) {
|
|
123
|
-
case
|
|
124
|
-
const data =
|
|
125
|
-
const initData =
|
|
126
|
-
const validatorId =
|
|
113
|
+
case MODULE_TYPE_ID_VALIDATOR: {
|
|
114
|
+
const data = encodeAbiParameters([{ type: 'bytes' }, { type: 'bytes' }, { type: 'bytes' }], [module.initData, '0x', '0x']);
|
|
115
|
+
const initData = concat([HOOK_INSTALLED_ADDRESS, data]);
|
|
116
|
+
const validatorId = concat(['0x01', module.address]);
|
|
127
117
|
return [
|
|
128
|
-
|
|
129
|
-
abi:
|
|
118
|
+
encodeFunctionData({
|
|
119
|
+
abi: parseAbi(['function installModule(uint256,address,bytes)']),
|
|
130
120
|
functionName: 'installModule',
|
|
131
121
|
args: [module.type, module.address, initData],
|
|
132
122
|
}),
|
|
133
|
-
|
|
134
|
-
abi:
|
|
123
|
+
encodeFunctionData({
|
|
124
|
+
abi: parseAbi(['function grantAccess(bytes21,bytes4,bool)']),
|
|
135
125
|
functionName: 'grantAccess',
|
|
136
126
|
args: [validatorId, '0xe9ae5c53', true],
|
|
137
127
|
}),
|
|
138
128
|
];
|
|
139
129
|
}
|
|
140
|
-
case
|
|
141
|
-
const data =
|
|
142
|
-
const initData =
|
|
130
|
+
case MODULE_TYPE_ID_EXECUTOR: {
|
|
131
|
+
const data = encodeAbiParameters([{ type: 'bytes' }, { type: 'bytes' }], [module.initData, '0x']);
|
|
132
|
+
const initData = concat([zeroAddress, data]);
|
|
143
133
|
return [
|
|
144
|
-
|
|
145
|
-
abi:
|
|
134
|
+
encodeFunctionData({
|
|
135
|
+
abi: parseAbi(['function installModule(uint256,address,bytes)']),
|
|
146
136
|
functionName: 'installModule',
|
|
147
137
|
args: [module.type, module.address, initData],
|
|
148
138
|
}),
|
|
149
139
|
];
|
|
150
140
|
}
|
|
151
|
-
case
|
|
152
|
-
const [selector, flags, selectorData] =
|
|
141
|
+
case MODULE_TYPE_ID_FALLBACK: {
|
|
142
|
+
const [selector, flags, selectorData] = decodeAbiParameters([
|
|
153
143
|
{ name: 'selector', type: 'bytes4' },
|
|
154
144
|
{ name: 'flags', type: 'bytes1' },
|
|
155
145
|
{ name: 'data', type: 'bytes' },
|
|
156
146
|
], module.initData);
|
|
157
|
-
const data =
|
|
158
|
-
const initData =
|
|
147
|
+
const data = encodeAbiParameters([{ type: 'bytes' }, { type: 'bytes' }], [concat([flags, selectorData]), '0x']);
|
|
148
|
+
const initData = concat([selector, HOOK_INSTALLED_ADDRESS, data]);
|
|
159
149
|
return [
|
|
160
|
-
|
|
161
|
-
abi:
|
|
150
|
+
encodeFunctionData({
|
|
151
|
+
abi: parseAbi(['function installModule(uint256,address,bytes)']),
|
|
162
152
|
functionName: 'installModule',
|
|
163
153
|
args: [module.type, module.address, initData],
|
|
164
154
|
}),
|
|
165
155
|
];
|
|
166
156
|
}
|
|
167
|
-
case
|
|
157
|
+
case MODULE_TYPE_ID_HOOK: {
|
|
168
158
|
return [
|
|
169
|
-
|
|
170
|
-
abi:
|
|
159
|
+
encodeFunctionData({
|
|
160
|
+
abi: parseAbi(['function installModule(uint256,address,bytes)']),
|
|
171
161
|
functionName: 'installModule',
|
|
172
162
|
args: [module.type, module.address, module.initData],
|
|
173
163
|
}),
|
|
@@ -176,9 +166,9 @@ function getInstallData(module) {
|
|
|
176
166
|
}
|
|
177
167
|
}
|
|
178
168
|
async function packSignature(signature, validator, transformSignature = (signature) => signature) {
|
|
179
|
-
const vId = validator.isRoot ? '0x00' :
|
|
180
|
-
const magicValueSigReplayable =
|
|
181
|
-
const packedSig =
|
|
169
|
+
const vId = validator.isRoot ? '0x00' : concat(['0x01', validator.address]);
|
|
170
|
+
const magicValueSigReplayable = keccak256(toHex('kernel.replayable.signature'));
|
|
171
|
+
const packedSig = concat([
|
|
182
172
|
vId,
|
|
183
173
|
magicValueSigReplayable,
|
|
184
174
|
transformSignature(signature),
|
|
@@ -186,7 +176,7 @@ async function packSignature(signature, validator, transformSignature = (signatu
|
|
|
186
176
|
return packedSig;
|
|
187
177
|
}
|
|
188
178
|
function wrapMessageHash(messageHash, accountAddress) {
|
|
189
|
-
const _domainSeparator =
|
|
179
|
+
const _domainSeparator = domainSeparator({
|
|
190
180
|
domain: {
|
|
191
181
|
name: 'Kernel',
|
|
192
182
|
version: KERNEL_VERSION,
|
|
@@ -194,36 +184,36 @@ function wrapMessageHash(messageHash, accountAddress) {
|
|
|
194
184
|
verifyingContract: accountAddress,
|
|
195
185
|
},
|
|
196
186
|
});
|
|
197
|
-
const kernelTypeHash =
|
|
198
|
-
const wrappedMessageHash =
|
|
199
|
-
const digest =
|
|
187
|
+
const kernelTypeHash = keccak256(stringToHex('Kernel(bytes32 hash)'));
|
|
188
|
+
const wrappedMessageHash = keccak256(encodeAbiParameters([{ type: 'bytes32' }, { type: 'bytes32' }], [kernelTypeHash, messageHash]));
|
|
189
|
+
const digest = keccak256(concatHex(['0x1901', _domainSeparator, wrappedMessageHash]));
|
|
200
190
|
return digest;
|
|
201
191
|
}
|
|
202
192
|
async function getSmartAccount(client, address, owners, validatorAddress, sign) {
|
|
203
193
|
return getBaseSmartAccount(address, client, validatorAddress, 'root', async () => {
|
|
204
|
-
return
|
|
194
|
+
return getMockSignature(owners);
|
|
205
195
|
}, sign);
|
|
206
196
|
}
|
|
207
197
|
async function getGuardianSmartAccount(client, address, guardians, validatorAddress, sign) {
|
|
208
198
|
return await getBaseSmartAccount(address, client, validatorAddress, 'validator', async () => {
|
|
209
|
-
return
|
|
199
|
+
return getMockSignature(guardians);
|
|
210
200
|
}, async (hash) => {
|
|
211
201
|
return await sign(hash);
|
|
212
202
|
});
|
|
213
203
|
}
|
|
214
204
|
async function getBaseSmartAccount(address, client, validatorAddress, validatorType, getStubSignature, signUserOperation) {
|
|
215
|
-
return await
|
|
205
|
+
return await toSmartAccount({
|
|
216
206
|
client,
|
|
217
207
|
entryPoint: {
|
|
218
|
-
abi:
|
|
219
|
-
address:
|
|
208
|
+
abi: entryPoint07Abi,
|
|
209
|
+
address: entryPoint07Address,
|
|
220
210
|
version: '0.7',
|
|
221
211
|
},
|
|
222
212
|
async decodeCalls() {
|
|
223
213
|
throw new Error('Not implemented');
|
|
224
214
|
},
|
|
225
215
|
async encodeCalls(calls) {
|
|
226
|
-
return
|
|
216
|
+
return encode7579Calls({
|
|
227
217
|
mode: {
|
|
228
218
|
type: calls.length > 1 ? 'batchcall' : 'call',
|
|
229
219
|
revertOnError: false,
|
|
@@ -245,10 +235,10 @@ async function getBaseSmartAccount(address, client, validatorAddress, validatorT
|
|
|
245
235
|
const type = validatorType === 'root' ? '0x00' : '0x01';
|
|
246
236
|
const identifier = validatorAddress;
|
|
247
237
|
const nonceKey = '0x0000';
|
|
248
|
-
const key =
|
|
249
|
-
return
|
|
238
|
+
const key = concat([mode, type, identifier, nonceKey]);
|
|
239
|
+
return getAccountNonce(client, {
|
|
250
240
|
address,
|
|
251
|
-
entryPointAddress:
|
|
241
|
+
entryPointAddress: entryPoint07Address,
|
|
252
242
|
key: BigInt(key),
|
|
253
243
|
});
|
|
254
244
|
},
|
|
@@ -265,13 +255,13 @@ async function getBaseSmartAccount(address, client, validatorAddress, validatorT
|
|
|
265
255
|
const { chainId = client.chain?.id, ...userOperation } = parameters;
|
|
266
256
|
if (!chainId)
|
|
267
257
|
throw new Error('Chain id not found');
|
|
268
|
-
const hash =
|
|
258
|
+
const hash = getUserOperationHash({
|
|
269
259
|
userOperation: {
|
|
270
260
|
...userOperation,
|
|
271
261
|
sender: userOperation.sender ?? (await this.getAddress()),
|
|
272
262
|
signature: '0x',
|
|
273
263
|
},
|
|
274
|
-
entryPointAddress:
|
|
264
|
+
entryPointAddress: entryPoint07Address,
|
|
275
265
|
entryPointVersion: '0.7',
|
|
276
266
|
chainId: chainId,
|
|
277
267
|
});
|
|
@@ -279,3 +269,4 @@ async function getBaseSmartAccount(address, client, validatorAddress, validatorT
|
|
|
279
269
|
},
|
|
280
270
|
});
|
|
281
271
|
}
|
|
272
|
+
export { getEip712Domain, getInstallData, getAddress, getDeployArgs, getSmartAccount, getGuardianSmartAccount, packSignature, wrapMessageHash, };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Abi, Account, Address, Chain, Hex, PublicClient } from 'viem';
|
|
2
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';
|
|
3
|
+
import type { Module } from '../modules/common.js';
|
|
4
|
+
import type { OwnerSet, RhinestoneAccountConfig } from '../types.js';
|
|
5
|
+
import { type ValidatorConfig } from './utils.js';
|
|
6
6
|
declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
7
7
|
salt: `0x${string}`;
|
|
8
8
|
factory: `0x${string}`;
|