@rhinestone/sdk 2.0.0-beta.4 → 2.0.0-beta.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/accounts/error.d.ts +2 -9
- package/dist/src/accounts/error.d.ts.map +1 -1
- package/dist/src/accounts/error.js +5 -11
- package/dist/src/accounts/hca.d.ts +25 -0
- package/dist/src/accounts/hca.d.ts.map +1 -0
- package/dist/src/accounts/hca.js +148 -0
- package/dist/src/accounts/index.d.ts +23 -10
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +170 -79
- package/dist/src/accounts/kernel.d.ts +1 -2
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +1 -8
- package/dist/src/accounts/nexus.d.ts +3 -2
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +33 -8
- package/dist/src/accounts/safe.d.ts +1 -2
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +3 -9
- 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 +48 -46
- package/dist/src/accounts/signing/message.d.ts.map +1 -1
- package/dist/src/accounts/signing/message.js +1 -4
- package/dist/src/accounts/signing/typedData.d.ts.map +1 -1
- package/dist/src/accounts/signing/typedData.js +1 -4
- package/dist/src/accounts/startale.d.ts +1 -2
- package/dist/src/accounts/startale.d.ts.map +1 -1
- package/dist/src/accounts/startale.js +6 -9
- package/dist/src/actions/ecdsa.js +5 -5
- package/dist/src/actions/index.js +2 -2
- package/dist/src/actions/mfa.js +2 -2
- package/dist/src/actions/passkeys.js +2 -2
- package/dist/src/actions/smart-sessions.d.ts +29 -5
- package/dist/src/actions/smart-sessions.d.ts.map +1 -1
- package/dist/src/actions/smart-sessions.js +38 -10
- package/dist/src/errors/index.d.ts +6 -4
- package/dist/src/errors/index.d.ts.map +1 -1
- package/dist/src/errors/index.js +6 -6
- package/dist/src/execution/error.d.ts +42 -11
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +53 -15
- package/dist/src/execution/index.d.ts +18 -18
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +27 -42
- package/dist/src/execution/utils.d.ts +55 -14
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +629 -82
- package/dist/src/index.d.ts +270 -38
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +89 -116
- package/dist/src/jwt-server/jcs.d.ts +1 -1
- package/dist/src/jwt-server/jcs.js +4 -2
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +0 -5
- package/dist/src/modules/read.d.ts +3 -2
- package/dist/src/modules/read.d.ts.map +1 -1
- package/dist/src/modules/read.js +52 -4
- package/dist/src/modules/validators/core.d.ts +6 -6
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +42 -39
- package/dist/src/modules/validators/cross-chain-permits.d.ts +21 -0
- package/dist/src/modules/validators/cross-chain-permits.d.ts.map +1 -0
- package/dist/src/modules/validators/cross-chain-permits.js +111 -0
- package/dist/src/modules/validators/permissions.d.ts +1 -0
- package/dist/src/modules/validators/permissions.d.ts.map +1 -1
- package/dist/src/modules/validators/permissions.js +192 -18
- package/dist/src/modules/validators/policies/claim/arbiters.d.ts +22 -0
- package/dist/src/modules/validators/policies/claim/arbiters.d.ts.map +1 -0
- package/dist/src/modules/validators/policies/claim/arbiters.js +57 -0
- package/dist/src/modules/validators/smart-sessions.d.ts +38 -9
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
- package/dist/src/modules/validators/smart-sessions.js +509 -92
- package/dist/src/orchestrator/caip2.d.ts +16 -3
- package/dist/src/orchestrator/caip2.d.ts.map +1 -1
- package/dist/src/orchestrator/caip2.js +38 -6
- package/dist/src/orchestrator/client.d.ts +2 -1
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +50 -24
- 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 +1 -1
- package/dist/src/orchestrator/destinations.d.ts +24 -0
- package/dist/src/orchestrator/destinations.d.ts.map +1 -0
- package/dist/src/orchestrator/destinations.js +59 -0
- package/dist/src/orchestrator/error.d.ts +95 -5
- package/dist/src/orchestrator/error.d.ts.map +1 -1
- package/dist/src/orchestrator/error.js +260 -4
- package/dist/src/orchestrator/index.d.ts +7 -5
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +4 -3
- package/dist/src/orchestrator/registry.d.ts +2 -1
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +13 -0
- package/dist/src/orchestrator/types.d.ts +92 -29
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/orchestrator/types.js +1 -5
- package/dist/src/orchestrator/wire.d.ts +30 -0
- package/dist/src/orchestrator/wire.d.ts.map +1 -0
- package/dist/src/orchestrator/wire.gen.d.ts +4290 -0
- package/dist/src/orchestrator/wire.gen.d.ts.map +1 -0
- package/dist/src/orchestrator/wire.gen.js +1 -0
- package/dist/src/orchestrator/wire.js +1 -0
- package/dist/src/smart-sessions/index.d.ts +6 -0
- package/dist/src/smart-sessions/index.d.ts.map +1 -0
- package/dist/src/smart-sessions/index.js +7 -0
- package/dist/src/types.d.ts +299 -31
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/index.d.ts +59 -0
- package/dist/src/utils/index.d.ts.map +1 -1
- package/dist/src/utils/index.js +59 -0
- package/package.json +5 -9
- package/dist/src/actions/recovery.d.ts +0 -33
- package/dist/src/actions/recovery.d.ts.map +0 -1
- package/dist/src/actions/recovery.js +0 -189
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { concat, createPublicClient, encodeAbiParameters, encodeFunctionData, hashTypedData, size, zeroAddress, } from 'viem';
|
|
1
|
+
import { concat, createPublicClient, encodeAbiParameters, encodeFunctionData, hashTypedData, isAddressEqual, size, zeroAddress, } from 'viem';
|
|
2
2
|
import { sendTransactionInternal, sendUserOperationInternal, waitForExecution, } from '../execution/index.js';
|
|
3
3
|
import { getIntentExecutor, getSetup } from '../modules/index.js';
|
|
4
|
+
import { MODULE_TYPE_ID_VALIDATOR } from '../modules/common.js';
|
|
5
|
+
import { getValidators as getValidatorsInternal, isValidatorInitialized, } from '../modules/read.js';
|
|
4
6
|
import { getOwnerValidator } from '../modules/validators/index.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { getAddress as getKernelAddress, getDeployArgs as getKernelDeployArgs, getEip712Domain as getKernelEip712Domain,
|
|
8
|
-
import { getAddress as getNexusAddress, getDefaultValidatorAddress as getNexusDefaultValidatorAddress, getDeployArgs as getNexusDeployArgs, getEip712Domain as getNexusEip712Domain, getEip7702InitCall as getNexusEip7702InitCall,
|
|
9
|
-
import { getAddress as getSafeAddress, getDeployArgs as getSafeDeployArgs, getEip712Domain as getSafeEip712Domain,
|
|
7
|
+
import { AccountConfigurationNotSupportedError, AccountError, DefaultValidatorAlreadyInitializedError, Eip712DomainNotAvailableError, Eip7702AccountMustHaveEoaError, Eip7702NotSupportedForAccountError, EoaAccountMustHaveAccountError, EoaSigningMethodNotConfiguredError, EoaSigningNotSupportedError, FactoryArgsNotAvailableError, isAccountError, ModuleInstallationNotSupportedError, OwnersFieldRequiredError, SigningNotSupportedForAccountError, WalletClientNoConnectedAccountError, } from './error.js';
|
|
8
|
+
import { getAddress as getHcaAddress, getDeployArgs as getHcaDeployArgs, getEip712Domain as getHcaEip712Domain, getSmartAccount as getHcaSmartAccount, packSignature as packHcaSignature, } from './hca.js';
|
|
9
|
+
import { getAddress as getKernelAddress, getDeployArgs as getKernelDeployArgs, getEip712Domain as getKernelEip712Domain, getInstallData as getKernelInstallData, getSmartAccount as getKernelSmartAccount, packSignature as packKernelSignature, wrapMessageHash as wrapKernelMessageHash, } from './kernel.js';
|
|
10
|
+
import { getAddress as getNexusAddress, getDefaultValidatorAddress as getNexusDefaultValidatorAddress, getDefaultValidatorInitData as getNexusDefaultValidatorInitData, getDeployArgs as getNexusDeployArgs, getEip712Domain as getNexusEip712Domain, getEip7702InitCall as getNexusEip7702InitCall, getInstallData as getNexusInstallData, getSmartAccount as getNexusSmartAccount, isDefaultValidatorConfigured as isNexusDefaultValidatorConfigured, packSignature as packNexusSignature, signEip7702InitData as signNexusEip7702InitData, } from './nexus.js';
|
|
11
|
+
import { getAddress as getSafeAddress, getDeployArgs as getSafeDeployArgs, getEip712Domain as getSafeEip712Domain, getInstallData as getSafeInstallData, getSmartAccount as getSafeSmartAccount, getV0DeployArgs as getSafeV0DeployArgs, packSignature as packSafeSignature, } from './safe.js';
|
|
10
12
|
import { convertOwnerSetToSignerSet } from './signing/common.js';
|
|
11
13
|
import { sign as signMessage } from './signing/message.js';
|
|
12
14
|
import { sign as signTypedData } from './signing/typedData.js';
|
|
13
|
-
import { getAddress as getStartaleAddress, getDeployArgs as getStartaleDeployArgs, getEip712Domain as getStartaleEip712Domain,
|
|
15
|
+
import { getAddress as getStartaleAddress, getDeployArgs as getStartaleDeployArgs, getEip712Domain as getStartaleEip712Domain, getInstallData as getStartaleInstallData, getSmartAccount as getStartaleSmartAccount, packSignature as packStartaleSignature, K1_DEFAULT_VALIDATOR_ADDRESS as STARTALE_K1_VALIDATOR_ADDRESS, } from './startale.js';
|
|
14
16
|
import { createTransport, getBundlerClient, } from './utils.js';
|
|
15
17
|
function getDeployArgs(config) {
|
|
16
18
|
const account = getAccountProvider(config);
|
|
@@ -27,6 +29,9 @@ function getDeployArgs(config) {
|
|
|
27
29
|
case 'startale': {
|
|
28
30
|
return getStartaleDeployArgs(config);
|
|
29
31
|
}
|
|
32
|
+
case 'hca': {
|
|
33
|
+
return getHcaDeployArgs(config);
|
|
34
|
+
}
|
|
30
35
|
case 'eoa': {
|
|
31
36
|
throw new Error('EOA accounts do not have deploy args');
|
|
32
37
|
}
|
|
@@ -102,7 +107,8 @@ async function signEip7702InitData(config) {
|
|
|
102
107
|
}
|
|
103
108
|
case 'safe':
|
|
104
109
|
case 'kernel':
|
|
105
|
-
case 'startale':
|
|
110
|
+
case 'startale':
|
|
111
|
+
case 'hca': {
|
|
106
112
|
throw new Eip7702NotSupportedForAccountError(account.type);
|
|
107
113
|
}
|
|
108
114
|
default: {
|
|
@@ -118,7 +124,8 @@ function getEip7702InitCall(config, signature) {
|
|
|
118
124
|
}
|
|
119
125
|
case 'safe':
|
|
120
126
|
case 'kernel':
|
|
121
|
-
case 'startale':
|
|
127
|
+
case 'startale':
|
|
128
|
+
case 'hca': {
|
|
122
129
|
throw new Eip7702NotSupportedForAccountError(account.type);
|
|
123
130
|
}
|
|
124
131
|
default: {
|
|
@@ -141,6 +148,9 @@ function getEip712Domain(config, chain) {
|
|
|
141
148
|
case 'startale': {
|
|
142
149
|
return getStartaleEip712Domain(config, chain);
|
|
143
150
|
}
|
|
151
|
+
case 'hca': {
|
|
152
|
+
return getHcaEip712Domain(config, chain);
|
|
153
|
+
}
|
|
144
154
|
case 'eoa': {
|
|
145
155
|
throw new Eip712DomainNotAvailableError('EOA accounts do not have an EIP-712 domain');
|
|
146
156
|
}
|
|
@@ -166,6 +176,9 @@ function getModuleInstallationCalls(config, module) {
|
|
|
166
176
|
case 'startale': {
|
|
167
177
|
return [getStartaleInstallData(module)];
|
|
168
178
|
}
|
|
179
|
+
case 'hca': {
|
|
180
|
+
throw new ModuleInstallationNotSupportedError(account.type);
|
|
181
|
+
}
|
|
169
182
|
case 'eoa': {
|
|
170
183
|
throw new ModuleInstallationNotSupportedError(account.type);
|
|
171
184
|
}
|
|
@@ -178,8 +191,44 @@ function getModuleInstallationCalls(config, module) {
|
|
|
178
191
|
data,
|
|
179
192
|
}));
|
|
180
193
|
}
|
|
181
|
-
|
|
194
|
+
// Like `getModuleInstallationCalls`, but aware of the Nexus default validator.
|
|
195
|
+
// On Nexus the OwnableValidator is the hardwired default validator: it can't be
|
|
196
|
+
// added via `installModule` (reverts `DefaultValidatorAlreadyInstalled`), and
|
|
197
|
+
// passkey-bootstrapped accounts never initialize it, so `addOwner` reverts with
|
|
198
|
+
// `NotInitialized`. For that case we initialize it directly via `onInstall`.
|
|
199
|
+
async function getValidatorInstallationCalls(config, chain, module) {
|
|
200
|
+
const account = getAccountProvider(config);
|
|
201
|
+
if (account.type === 'nexus') {
|
|
202
|
+
const defaultValidatorAddress = getNexusDefaultValidatorAddress(account.version);
|
|
203
|
+
if (module.address.toLowerCase() === defaultValidatorAddress.toLowerCase()) {
|
|
204
|
+
// Treat the validator as initialized if the account's deployment will
|
|
205
|
+
// initialize it (config check, covers not-yet-deployed accounts) or if
|
|
206
|
+
// it is already initialized on-chain (covers accounts where ECDSA was
|
|
207
|
+
// enabled separately after deployment).
|
|
208
|
+
const initialized = isNexusDefaultValidatorConfigured(config) ||
|
|
209
|
+
(await isValidatorInitialized(getAddress(config), chain, defaultValidatorAddress, config.provider));
|
|
210
|
+
if (initialized) {
|
|
211
|
+
throw new DefaultValidatorAlreadyInitializedError();
|
|
212
|
+
}
|
|
213
|
+
return [
|
|
214
|
+
{
|
|
215
|
+
to: defaultValidatorAddress,
|
|
216
|
+
value: 0n,
|
|
217
|
+
data: getNexusDefaultValidatorInitData(module),
|
|
218
|
+
},
|
|
219
|
+
];
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return getModuleInstallationCalls(config, module);
|
|
223
|
+
}
|
|
224
|
+
// SentinelList head pointer used by ERC-7579 module managers (Nexus, Safe7579,
|
|
225
|
+
// Startale). Validator/executor uninstall on these accounts decodes the
|
|
226
|
+
// `deInitData` slot as `(address prev, bytes moduleDeInit)`, where `prev`
|
|
227
|
+
// identifies the preceding linked-list entry to repair on removal.
|
|
228
|
+
const SENTINEL_LIST_HEAD = '0x0000000000000000000000000000000000000001';
|
|
229
|
+
async function getModuleUninstallationCalls(config, chain, module) {
|
|
182
230
|
const address = getAddress(config);
|
|
231
|
+
const onChainDeInitData = await resolveOnChainDeInitData(config, chain, address, module);
|
|
183
232
|
const data = encodeFunctionData({
|
|
184
233
|
abi: [
|
|
185
234
|
{
|
|
@@ -204,10 +253,46 @@ function getModuleUninstallationCalls(config, module) {
|
|
|
204
253
|
},
|
|
205
254
|
],
|
|
206
255
|
functionName: 'uninstallModule',
|
|
207
|
-
args: [module.type, module.address,
|
|
256
|
+
args: [module.type, module.address, onChainDeInitData],
|
|
208
257
|
});
|
|
209
258
|
return [{ to: address, data, value: 0n }];
|
|
210
259
|
}
|
|
260
|
+
/**
|
|
261
|
+
* Build the value the account expects in `uninstallModule`'s third argument.
|
|
262
|
+
*
|
|
263
|
+
* `Module.deInitData` carries module-level bytes (mirroring `Module.initData`,
|
|
264
|
+
* what the module's `onUninstall` sees). ERC-7579 accounts that store
|
|
265
|
+
* validators / executors in a SentinelList — Nexus, Safe7579, Startale —
|
|
266
|
+
* require an account-level wrapper `abi.encode(prev, moduleDeInit)` so they
|
|
267
|
+
* can pop the entry from the linked list. Kernel uses different storage and
|
|
268
|
+
* treats this slot as raw module bytes, so we pass `module.deInitData` through
|
|
269
|
+
* unchanged.
|
|
270
|
+
*
|
|
271
|
+
* Scope: validator type only — there are no public actions to disable
|
|
272
|
+
* executor modules today.
|
|
273
|
+
*/
|
|
274
|
+
async function resolveOnChainDeInitData(config, chain, account, module) {
|
|
275
|
+
if (module.type !== MODULE_TYPE_ID_VALIDATOR) {
|
|
276
|
+
return module.deInitData;
|
|
277
|
+
}
|
|
278
|
+
const accountType = getAccountProvider(config).type;
|
|
279
|
+
if (accountType !== 'nexus' &&
|
|
280
|
+
accountType !== 'safe' &&
|
|
281
|
+
accountType !== 'startale') {
|
|
282
|
+
return module.deInitData;
|
|
283
|
+
}
|
|
284
|
+
const validators = await getValidatorsInternal(accountType, account, chain, config.provider);
|
|
285
|
+
const targetLower = module.address.toLowerCase();
|
|
286
|
+
const index = validators.findIndex((v) => v.toLowerCase() === targetLower);
|
|
287
|
+
if (index === -1) {
|
|
288
|
+
// Not installed; pass through unchanged. The account's `uninstallModule`
|
|
289
|
+
// will surface a `ModuleNotInstalled` revert with the original module
|
|
290
|
+
// address, which is more useful than a silent abi.decode mismatch.
|
|
291
|
+
return module.deInitData;
|
|
292
|
+
}
|
|
293
|
+
const prev = index === 0 ? SENTINEL_LIST_HEAD : validators[index - 1];
|
|
294
|
+
return encodeAbiParameters([{ type: 'address' }, { type: 'bytes' }], [prev, module.deInitData]);
|
|
295
|
+
}
|
|
211
296
|
function getAddress(config) {
|
|
212
297
|
if (is7702(config)) {
|
|
213
298
|
if (!config.eoa) {
|
|
@@ -229,6 +314,9 @@ function getAddress(config) {
|
|
|
229
314
|
case 'startale': {
|
|
230
315
|
return getStartaleAddress(config);
|
|
231
316
|
}
|
|
317
|
+
case 'hca': {
|
|
318
|
+
return getHcaAddress(config);
|
|
319
|
+
}
|
|
232
320
|
case 'eoa': {
|
|
233
321
|
if (!config.eoa) {
|
|
234
322
|
throw new AccountError({
|
|
@@ -249,38 +337,41 @@ function checkAddress(config) {
|
|
|
249
337
|
}
|
|
250
338
|
return initData.address.toLowerCase() === getAddress(config).toLowerCase();
|
|
251
339
|
}
|
|
252
|
-
|
|
253
|
-
async function getEip1271Signature(config, signers, chain, validator, hash, transformSignature = (signature) => signature) {
|
|
254
|
-
if (config.account?.type === 'eoa') {
|
|
255
|
-
throw new EoaSigningNotSupportedError('packed signatures');
|
|
256
|
-
}
|
|
257
|
-
signers = signers ?? convertOwnerSetToSignerSet(config.owners);
|
|
258
|
-
const signFn = (hash) => signMessage(signers, chain, address, hash, false);
|
|
340
|
+
async function packAccountSignature(config, signature, validator, transformSignature = (signature) => signature) {
|
|
259
341
|
const account = getAccountProvider(config);
|
|
260
|
-
const address = getAddress(config);
|
|
261
342
|
switch (account.type) {
|
|
262
343
|
case 'safe': {
|
|
263
|
-
const signature = await signFn(hash);
|
|
264
344
|
return packSafeSignature(signature, validator, transformSignature);
|
|
265
345
|
}
|
|
266
346
|
case 'nexus': {
|
|
267
|
-
const signature = await signFn(hash);
|
|
268
347
|
const defaultValidatorAddress = getNexusDefaultValidatorAddress(account.version);
|
|
269
348
|
return packNexusSignature(signature, validator, transformSignature, defaultValidatorAddress);
|
|
270
349
|
}
|
|
271
350
|
case 'kernel': {
|
|
272
|
-
const signature = await signFn(wrapKernelMessageHash(hash, address));
|
|
273
351
|
return packKernelSignature(signature, validator, transformSignature);
|
|
274
352
|
}
|
|
275
353
|
case 'startale': {
|
|
276
|
-
const signature = await signFn(hash);
|
|
277
354
|
return packStartaleSignature(signature, validator, transformSignature);
|
|
278
355
|
}
|
|
356
|
+
case 'hca': {
|
|
357
|
+
return packHcaSignature(signature, validator, transformSignature);
|
|
358
|
+
}
|
|
279
359
|
default: {
|
|
280
360
|
throw new Error(`Unsupported account type: ${account.type}`);
|
|
281
361
|
}
|
|
282
362
|
}
|
|
283
363
|
}
|
|
364
|
+
async function getEip1271Signature(config, signers, chain, validator, hash, transformSignature = (signature) => signature) {
|
|
365
|
+
if (config.account?.type === 'eoa') {
|
|
366
|
+
throw new EoaSigningNotSupportedError('packed signatures');
|
|
367
|
+
}
|
|
368
|
+
signers = signers ?? convertOwnerSetToSignerSet(config.owners);
|
|
369
|
+
const account = getAccountProvider(config);
|
|
370
|
+
const address = getAddress(config);
|
|
371
|
+
const signedHash = account.type === 'kernel' ? wrapKernelMessageHash(hash, address) : hash;
|
|
372
|
+
const signature = await signMessage(signers, chain, address, signedHash, false);
|
|
373
|
+
return packAccountSignature(config, signature, validator, transformSignature);
|
|
374
|
+
}
|
|
284
375
|
// Signs and packs a signature to be used by the emissary validator
|
|
285
376
|
async function getEmissarySignature(config, signers, chain, hash, transformSignature = (signature) => signature) {
|
|
286
377
|
if (config.account?.type === 'eoa') {
|
|
@@ -299,32 +390,52 @@ async function getTypedDataPackedSignature(config, signers, chain, validator, pa
|
|
|
299
390
|
}
|
|
300
391
|
const address = getAddress(config);
|
|
301
392
|
signers = signers ?? convertOwnerSetToSignerSet(config.owners);
|
|
302
|
-
const signFn = (parameters) => signTypedData(signers, chain, address, parameters);
|
|
303
393
|
const account = getAccountProvider(config);
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
394
|
+
const signature = account.type === 'kernel'
|
|
395
|
+
? await signMessage(signers, chain, address, wrapKernelMessageHash(hashTypedData(parameters), address), false)
|
|
396
|
+
: await signTypedData(signers, chain, address, parameters);
|
|
397
|
+
return packAccountSignature(config, signature, validator, transformSignature);
|
|
398
|
+
}
|
|
399
|
+
async function getOwnerEcdsaSignature(config, chain, parameters, owner, module, validatorSupportsEip712) {
|
|
400
|
+
if (config.account?.type === 'eoa') {
|
|
401
|
+
throw new EoaSigningNotSupportedError('packed signatures');
|
|
402
|
+
}
|
|
403
|
+
const address = getAddress(config);
|
|
404
|
+
const signers = {
|
|
405
|
+
type: 'owner',
|
|
406
|
+
kind: 'ecdsa',
|
|
407
|
+
accounts: [owner],
|
|
408
|
+
module,
|
|
409
|
+
};
|
|
410
|
+
const accountProvider = getAccountProvider(config);
|
|
411
|
+
if (accountProvider.type === 'kernel') {
|
|
412
|
+
return signMessage(signers, chain, address, wrapKernelMessageHash(hashTypedData(parameters), address), false);
|
|
413
|
+
}
|
|
414
|
+
if (!validatorSupportsEip712) {
|
|
415
|
+
return signMessage(signers, chain, address, hashTypedData(parameters), false);
|
|
416
|
+
}
|
|
417
|
+
return signTypedData(signers, chain, address, parameters);
|
|
418
|
+
}
|
|
419
|
+
async function getOwnerPasskeySignature(config, parameters, owner, validatorSupportsEip712) {
|
|
420
|
+
if (config.account?.type === 'eoa') {
|
|
421
|
+
throw new EoaSigningNotSupportedError('packed signatures');
|
|
422
|
+
}
|
|
423
|
+
const address = getAddress(config);
|
|
424
|
+
const accountProvider = getAccountProvider(config);
|
|
425
|
+
if (accountProvider.type === 'kernel') {
|
|
426
|
+
const { webauthn, signature } = await owner.sign({
|
|
427
|
+
hash: wrapKernelMessageHash(hashTypedData(parameters), address),
|
|
428
|
+
});
|
|
429
|
+
return { webauthn, signature };
|
|
430
|
+
}
|
|
431
|
+
if (!validatorSupportsEip712) {
|
|
432
|
+
const { webauthn, signature } = await owner.sign({
|
|
433
|
+
hash: hashTypedData(parameters),
|
|
434
|
+
});
|
|
435
|
+
return { webauthn, signature };
|
|
327
436
|
}
|
|
437
|
+
const { webauthn, signature } = await owner.signTypedData(parameters);
|
|
438
|
+
return { webauthn, signature };
|
|
328
439
|
}
|
|
329
440
|
async function isDeployed(config, chain) {
|
|
330
441
|
const account = getAccountProvider(config);
|
|
@@ -377,7 +488,8 @@ async function deploy(config, chain, params) {
|
|
|
377
488
|
// Useful for existing (already deployed) accounts
|
|
378
489
|
async function setup(config, chain) {
|
|
379
490
|
const account = getAccountProvider(config);
|
|
380
|
-
|
|
491
|
+
// HCA accounts are locked and cannot install modules, so there is nothing to set up.
|
|
492
|
+
if (account.type === 'eoa' || account.type === 'hca') {
|
|
381
493
|
return false;
|
|
382
494
|
}
|
|
383
495
|
const modules = getSetup(config);
|
|
@@ -391,7 +503,12 @@ async function setup(config, chain) {
|
|
|
391
503
|
...modules.executors,
|
|
392
504
|
...modules.fallbacks,
|
|
393
505
|
...modules.hooks,
|
|
394
|
-
]
|
|
506
|
+
].filter(
|
|
507
|
+
// Startale's K1 validator is the account's built-in default validator, set
|
|
508
|
+
// at deployment — it is never a regular 7579 module, so isModuleInstalled
|
|
509
|
+
// reports false and trying to install it reverts. Skip it.
|
|
510
|
+
(module) => !(account.type === 'startale' &&
|
|
511
|
+
isAddressEqual(module.address, STARTALE_K1_VALIDATOR_ADDRESS)));
|
|
395
512
|
// Check if the modules are already installed
|
|
396
513
|
const installedResults = await publicClient.multicall({
|
|
397
514
|
contracts: allModules.map((module) => ({
|
|
@@ -541,34 +658,8 @@ async function getSmartAccount(config, client, chain) {
|
|
|
541
658
|
case 'startale': {
|
|
542
659
|
return getStartaleSmartAccount(client, address, config.owners, ownerValidator.address, signFn);
|
|
543
660
|
}
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
async function getGuardianSmartAccount(config, client, chain, guardians) {
|
|
547
|
-
const address = getAddress(config);
|
|
548
|
-
const accounts = guardians.type === 'ecdsa' ? guardians.accounts : [];
|
|
549
|
-
const socialRecoveryValidator = getSocialRecoveryValidator(accounts);
|
|
550
|
-
if (!socialRecoveryValidator) {
|
|
551
|
-
throw new Error('Social recovery is not available');
|
|
552
|
-
}
|
|
553
|
-
const signers = {
|
|
554
|
-
type: 'guardians',
|
|
555
|
-
guardians: accounts,
|
|
556
|
-
};
|
|
557
|
-
const signFn = (hash) => signMessage(signers, chain, address, hash, true);
|
|
558
|
-
const account = getAccountProvider(config);
|
|
559
|
-
switch (account.type) {
|
|
560
|
-
case 'safe': {
|
|
561
|
-
return getSafeGuardianSmartAccount(client, address, guardians, socialRecoveryValidator.address, signFn);
|
|
562
|
-
}
|
|
563
|
-
case 'nexus': {
|
|
564
|
-
const defaultValidatorAddress = getNexusDefaultValidatorAddress(account.version);
|
|
565
|
-
return getNexusGuardianSmartAccount(client, address, guardians, socialRecoveryValidator.address, signFn, defaultValidatorAddress);
|
|
566
|
-
}
|
|
567
|
-
case 'kernel': {
|
|
568
|
-
return getKernelGuardianSmartAccount(client, address, guardians, socialRecoveryValidator.address, signFn);
|
|
569
|
-
}
|
|
570
|
-
case 'startale': {
|
|
571
|
-
return getStartaleGuardianSmartAccount(client, address, guardians, socialRecoveryValidator.address, signFn);
|
|
661
|
+
case 'hca': {
|
|
662
|
+
return getHcaSmartAccount(client, address, config.owners, ownerValidator.address, signFn);
|
|
572
663
|
}
|
|
573
664
|
}
|
|
574
665
|
}
|
|
@@ -584,6 +675,6 @@ function getAccountProvider(config) {
|
|
|
584
675
|
type: 'nexus',
|
|
585
676
|
};
|
|
586
677
|
}
|
|
587
|
-
export { getEip712Domain, getModuleInstallationCalls, getModuleUninstallationCalls, getAddress, checkAddress, getAccountProvider, getInitCode, getV0InitCode, signEip7702InitData, getEip7702InitCall, is7702, isDeployed, deploy, setup, toErc6492Signature, getSmartAccount,
|
|
678
|
+
export { getEip712Domain, getModuleInstallationCalls, getValidatorInstallationCalls, getModuleUninstallationCalls, getAddress, checkAddress, getAccountProvider, getInitCode, getV0InitCode, signEip7702InitData, getEip7702InitCall, is7702, isDeployed, deploy, setup, toErc6492Signature, getSmartAccount, getEip1271Signature, getEmissarySignature, getOwnerEcdsaSignature, getOwnerPasskeySignature, getTypedDataPackedSignature, packAccountSignature,
|
|
588
679
|
// Errors
|
|
589
|
-
isAccountError, AccountError, AccountConfigurationNotSupportedError, Eip712DomainNotAvailableError, Eip7702AccountMustHaveEoaError, Eip7702NotSupportedForAccountError, EoaAccountMustHaveAccountError, EoaSigningMethodNotConfiguredError, EoaSigningNotSupportedError,
|
|
680
|
+
isAccountError, AccountError, AccountConfigurationNotSupportedError, DefaultValidatorAlreadyInitializedError, Eip712DomainNotAvailableError, Eip7702AccountMustHaveEoaError, Eip7702NotSupportedForAccountError, EoaAccountMustHaveAccountError, EoaSigningMethodNotConfiguredError, EoaSigningNotSupportedError, FactoryArgsNotAvailableError, ModuleInstallationNotSupportedError, OwnersFieldRequiredError, SigningNotSupportedForAccountError, WalletClientNoConnectedAccountError, };
|
|
@@ -22,6 +22,5 @@ declare function getInstallData(module: Module): Hex[];
|
|
|
22
22
|
declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
|
|
23
23
|
declare function wrapMessageHash(messageHash: Hex, accountAddress: Hex): Hex;
|
|
24
24
|
declare function getSmartAccount(client: PublicClient, address: Address, owners: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
25
|
-
|
|
26
|
-
export { getEip712Domain, getInstallData, getAddress, getDeployArgs, getSmartAccount, getGuardianSmartAccount, packSignature, wrapMessageHash, };
|
|
25
|
+
export { getEip712Domain, getInstallData, getAddress, getDeployArgs, getSmartAccount, packSignature, wrapMessageHash, };
|
|
27
26
|
//# sourceMappingURL=kernel.d.ts.map
|
|
@@ -1 +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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e,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;AA+ED,OAAO,EACL,eAAe,EACf,cAAc,EACd,UAAU,EACV,aAAa,EACb,eAAe,EACf,aAAa,EACb,eAAe,GAChB,CAAA"}
|
|
@@ -194,13 +194,6 @@ async function getSmartAccount(client, address, owners, validatorAddress, sign)
|
|
|
194
194
|
return getMockSignature(owners);
|
|
195
195
|
}, sign);
|
|
196
196
|
}
|
|
197
|
-
async function getGuardianSmartAccount(client, address, guardians, validatorAddress, sign) {
|
|
198
|
-
return await getBaseSmartAccount(address, client, validatorAddress, 'validator', async () => {
|
|
199
|
-
return getMockSignature(guardians);
|
|
200
|
-
}, async (hash) => {
|
|
201
|
-
return await sign(hash);
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
197
|
async function getBaseSmartAccount(address, client, validatorAddress, validatorType, getStubSignature, signUserOperation) {
|
|
205
198
|
return await toSmartAccount({
|
|
206
199
|
client,
|
|
@@ -269,4 +262,4 @@ async function getBaseSmartAccount(address, client, validatorAddress, validatorT
|
|
|
269
262
|
},
|
|
270
263
|
});
|
|
271
264
|
}
|
|
272
|
-
export { getEip712Domain, getInstallData, getAddress, getDeployArgs, getSmartAccount,
|
|
265
|
+
export { getEip712Domain, getInstallData, getAddress, getDeployArgs, getSmartAccount, packSignature, wrapMessageHash, };
|
|
@@ -20,14 +20,15 @@ declare function getEip712Domain(config: RhinestoneAccountConfig, chain: Chain):
|
|
|
20
20
|
salt: "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
21
21
|
};
|
|
22
22
|
declare function getInstallData(module: Module): `0x${string}`;
|
|
23
|
+
declare function getDefaultValidatorInitData(module: Module): Hex;
|
|
24
|
+
declare function isDefaultValidatorConfigured(config: RhinestoneAccountConfig): boolean;
|
|
23
25
|
declare function getDefaultValidatorAddress(version: '1.0.2' | '1.2.0' | 'rhinestone-1.0.0-beta' | 'rhinestone-1.0.0' | undefined): Address;
|
|
24
26
|
declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex, defaultValidatorAddress?: Address): Promise<`0x${string}`>;
|
|
25
27
|
declare function getSmartAccount(client: PublicClient, address: Address, owners: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>, defaultValidatorAddress?: Address): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
26
|
-
declare function getGuardianSmartAccount(client: PublicClient, address: Address, guardians: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>, defaultValidatorAddress?: Address): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
27
28
|
declare function signEip7702InitData(config: RhinestoneAccountConfig, eoa: Account): Promise<`0x${string}`>;
|
|
28
29
|
declare function getEip7702InitCall(config: RhinestoneAccountConfig, signature: Hex): {
|
|
29
30
|
initData: `0x${string}`;
|
|
30
31
|
contract: `0x${string}`;
|
|
31
32
|
};
|
|
32
|
-
export { getEip712Domain, getInstallData, getAddress, getDefaultValidatorAddress, packSignature, getDeployArgs, getSmartAccount,
|
|
33
|
+
export { getEip712Domain, getInstallData, getDefaultValidatorInitData, isDefaultValidatorConfigured, getAddress, getDefaultValidatorAddress, packSignature, getDeployArgs, getSmartAccount, signEip7702InitData, getEip7702InitCall, };
|
|
33
34
|
//# 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,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAe3E,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,0BAA0B,EA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A0C1E;AA6FD,OAAO,EACL,eAAe,EACf,cAAc,EACd,2BAA2B,EAC3B,4BAA4B,EAC5B,UAAU,EACV,0BAA0B,EAC1B,aAAa,EACb,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,kBAAkB,GACnB,CAAA"}
|
|
@@ -188,6 +188,38 @@ function getInstallData(module) {
|
|
|
188
188
|
args: [module.type, module.address, module.initData],
|
|
189
189
|
});
|
|
190
190
|
}
|
|
191
|
+
// On Nexus the OwnableValidator is the hardwired default validator. It cannot
|
|
192
|
+
// be added via `installModule` (reverts `DefaultValidatorAlreadyInstalled`), so
|
|
193
|
+
// it is initialized out-of-band by calling its `onInstall` directly with the
|
|
194
|
+
// same init data `installModule` would have passed (`abi.encode(threshold, owners)`).
|
|
195
|
+
function getDefaultValidatorInitData(module) {
|
|
196
|
+
return encodeFunctionData({
|
|
197
|
+
abi: [
|
|
198
|
+
{
|
|
199
|
+
type: 'function',
|
|
200
|
+
name: 'onInstall',
|
|
201
|
+
inputs: [{ type: 'bytes', name: 'data' }],
|
|
202
|
+
outputs: [],
|
|
203
|
+
stateMutability: 'nonpayable',
|
|
204
|
+
},
|
|
205
|
+
],
|
|
206
|
+
functionName: 'onInstall',
|
|
207
|
+
args: [module.initData],
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
// Whether the deploy bootstrap will initialize the default validator — i.e. the
|
|
211
|
+
// account is configured with an Ownable/ECDSA owner set. Mirrors the
|
|
212
|
+
// `defaultValidatorInitData` computation in `getDeployArgs`, so a counterfactual
|
|
213
|
+
// (not-yet-deployed) account whose deployment initializes the default validator
|
|
214
|
+
// is treated as already-initialized rather than emitting a second `onInstall`.
|
|
215
|
+
function isDefaultValidatorConfigured(config) {
|
|
216
|
+
if (config.initData) {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
const moduleSetup = getModuleSetup(config);
|
|
220
|
+
const defaultValidator = moduleSetup.validators.find((v) => v.address === NEXUS_DEFAULT_VALIDATOR_ADDRESS);
|
|
221
|
+
return defaultValidator ? size(defaultValidator.initData) > 0 : false;
|
|
222
|
+
}
|
|
191
223
|
function getDefaultValidatorAddress(version) {
|
|
192
224
|
if (!version) {
|
|
193
225
|
return NEXUS_DEFAULT_VALIDATOR_ADDRESS;
|
|
@@ -215,13 +247,6 @@ async function getSmartAccount(client, address, owners, validatorAddress, sign,
|
|
|
215
247
|
return getMockSignature(owners);
|
|
216
248
|
}, sign, defaultValidatorAddress);
|
|
217
249
|
}
|
|
218
|
-
async function getGuardianSmartAccount(client, address, guardians, validatorAddress, sign, defaultValidatorAddress = NEXUS_DEFAULT_VALIDATOR_ADDRESS) {
|
|
219
|
-
return await getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
220
|
-
return getMockSignature(guardians);
|
|
221
|
-
}, async (hash) => {
|
|
222
|
-
return await sign(hash);
|
|
223
|
-
}, defaultValidatorAddress);
|
|
224
|
-
}
|
|
225
250
|
async function getBaseSmartAccount(address, client, nonceValidatorAddress, getStubSignature, signUserOperation, defaultValidatorAddress) {
|
|
226
251
|
return await toSmartAccount({
|
|
227
252
|
client,
|
|
@@ -441,4 +466,4 @@ function tryDecodeV0FactoryData(factory, factoryData) {
|
|
|
441
466
|
function isAbiDecodingError(error) {
|
|
442
467
|
return (error instanceof Error && error.name === 'AbiFunctionSignatureNotFoundError');
|
|
443
468
|
}
|
|
444
|
-
export { getEip712Domain, getInstallData, getAddress, getDefaultValidatorAddress, packSignature, getDeployArgs, getSmartAccount,
|
|
469
|
+
export { getEip712Domain, getInstallData, getDefaultValidatorInitData, isDefaultValidatorConfigured, getAddress, getDefaultValidatorAddress, packSignature, getDeployArgs, getSmartAccount, signEip7702InitData, getEip7702InitCall, };
|
|
@@ -28,6 +28,5 @@ declare function getEip712Domain(config: RhinestoneAccountConfig, chain: Chain):
|
|
|
28
28
|
declare function getInstallData(module: Module): `0x${string}`;
|
|
29
29
|
declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
|
|
30
30
|
declare function getSmartAccount(client: PublicClient, address: Address, owners: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
31
|
-
|
|
32
|
-
export { getEip712Domain, getInstallData, getAddress, packSignature, getDeployArgs, getV0DeployArgs, getSmartAccount, getGuardianSmartAccount, };
|
|
31
|
+
export { getEip712Domain, getInstallData, getAddress, packSignature, getDeployArgs, getV0DeployArgs, getSmartAccount, };
|
|
33
32
|
//# sourceMappingURL=safe.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../../../accounts/safe.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EACR,KAAK,OAAO,EACZ,KAAK,KAAK,EAOV,KAAK,GAAG,EAER,KAAK,YAAY,EAKlB,MAAM,MAAM,CAAA;AACb,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAEhC,MAAM,0BAA0B,CAAA;AAGjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAM/C,OAAO,KAAK,EAAE,QAAQ,EAAE,uBAAuB,EAAe,MAAM,UAAU,CAAA;AAM9E,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAoBhF,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;SAmGrD;AAED,iBAAS,eAAe,CAAC,MAAM,EAAE,uBAAuB;;;;;;EAgFvD;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,iBAoBlD;AAED,iBAAS,eAAe,CAAC,MAAM,EAAE,uBAAuB,EAAE,KAAK,EAAE,KAAK;;;;;;EAarE;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE,MAAM,iBA2BrC;AAED,iBAAe,aAAa,CAC1B,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,eAAe,EAC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,OAAO,EAChB,MAAM,EAAE,QAAQ,EAChB,gBAAgB,EAAE,OAAO,EACzB,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,iEAWlC;AA2GD,OAAO,EACL,eAAe,EACf,cAAc,EACd,UAAU,EACV,aAAa,EACb,aAAa,EACb,eAAe,EACf,eAAe,GAChB,CAAA"}
|
|
@@ -239,13 +239,6 @@ async function getSmartAccount(client, address, owners, validatorAddress, sign)
|
|
|
239
239
|
return getMockSignature(owners);
|
|
240
240
|
}, sign);
|
|
241
241
|
}
|
|
242
|
-
async function getGuardianSmartAccount(client, address, guardians, validatorAddress, sign) {
|
|
243
|
-
return await getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
244
|
-
return getMockSignature(guardians);
|
|
245
|
-
}, async (hash) => {
|
|
246
|
-
return await sign(hash);
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
242
|
async function getBaseSmartAccount(address, client, validatorAddress, getStubSignature, signUserOperation) {
|
|
250
243
|
return await toSmartAccount({
|
|
251
244
|
client,
|
|
@@ -317,8 +310,9 @@ function getOwners(config) {
|
|
|
317
310
|
const ownerSet = config.owners;
|
|
318
311
|
switch (ownerSet.type) {
|
|
319
312
|
case 'ecdsa':
|
|
320
|
-
case 'ens':
|
|
321
313
|
return ownerSet.accounts.map((account) => account.address);
|
|
314
|
+
case 'ens':
|
|
315
|
+
return ownerSet.owners.map((o) => o.account.address);
|
|
322
316
|
case 'passkey':
|
|
323
317
|
return [NO_SAFE_OWNER_ADDRESS];
|
|
324
318
|
case 'multi-factor':
|
|
@@ -340,4 +334,4 @@ function getThreshold(config) {
|
|
|
340
334
|
return 1n;
|
|
341
335
|
}
|
|
342
336
|
}
|
|
343
|
-
export { getEip712Domain, getInstallData, getAddress, packSignature, getDeployArgs, getV0DeployArgs, getSmartAccount,
|
|
337
|
+
export { getEip712Domain, getInstallData, getAddress, packSignature, getDeployArgs, getV0DeployArgs, getSmartAccount, };
|
|
@@ -21,12 +21,18 @@ declare function signWithMultiFactorAuth<T>(signers: SignerSet & {
|
|
|
21
21
|
type: 'owner';
|
|
22
22
|
kind: 'multi-factor';
|
|
23
23
|
}, chain: Chain, address: Address, params: T, isUserOpHash: boolean, signMain: (signers: SignerSet, chain: Chain, address: Address, params: T, isUserOpHash: boolean) => Promise<Hex>): Promise<Hex>;
|
|
24
|
+
declare function packMultiFactorOwnerSignatures(entries: {
|
|
25
|
+
id: number | Hex;
|
|
26
|
+
validatorAddress: Address;
|
|
27
|
+
signature: Hex;
|
|
28
|
+
}[]): Hex;
|
|
29
|
+
declare function packPasskeyOwnerSignatures(chain: Chain, address: Address, publicKeys: Hex[], signatures: {
|
|
30
|
+
webauthn: WebAuthnSignMetadata;
|
|
31
|
+
signature: Hex;
|
|
32
|
+
}[], module?: Address): Hex;
|
|
24
33
|
declare function signWithSession(signers: ResolvedSessionSignerSet, chain: Chain, address: Address, hash: Hex, signMain: (signers: SignerSet, chain: Chain, address: Address, hash: Hex, isUserOpHash: boolean) => Promise<Hex>): Promise<Hex>;
|
|
25
|
-
declare function signWithGuardians<T>(signers: SignerSet & {
|
|
26
|
-
type: 'guardians';
|
|
27
|
-
}, params: T, signingFunctions: SigningFunctions<T>): Promise<Hex>;
|
|
28
34
|
declare function signWithOwners<T>(signers: SignerSet & {
|
|
29
35
|
type: 'owner';
|
|
30
36
|
}, chain: Chain, address: Address, params: T, signingFunctions: SigningFunctions<T>, isUserOpHash: boolean, signMain: (signers: SignerSet, chain: Chain, address: Address, params: T, isUserOpHash: boolean) => Promise<Hex>): Promise<Hex>;
|
|
31
|
-
export { convertOwnerSetToSignerSet, signWithMultiFactorAuth, signWithSession,
|
|
37
|
+
export { convertOwnerSetToSignerSet, packMultiFactorOwnerSignatures, packPasskeyOwnerSignatures, signWithMultiFactorAuth, signWithSession, signWithOwners, type SigningFunctions, };
|
|
32
38
|
//# sourceMappingURL=common.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../accounts/signing/common.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,KAAK,EAMV,KAAK,GAAG,EAKT,MAAM,MAAM,CAAA;AACb,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAQ/D,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,yCAAyC,CAAA;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAStD,iBAAS,0BAA0B,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../accounts/signing/common.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,KAAK,EAMV,KAAK,GAAG,EAKT,MAAM,MAAM,CAAA;AACb,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAQ/D,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,yCAAyC,CAAA;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAStD,iBAAS,0BAA0B,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,CAmE/D;AAED,KAAK,oBAAoB,GAAG;IAC1B,iBAAiB,EAAE,GAAG,CAAA;IACtB,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACnC,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,wBAAwB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC/C,CAAA;AAED,KAAK,gBAAgB,CAAC,CAAC,IAAI;IACzB,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,O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