@alchemy/smart-accounts 5.0.0-beta.3 → 5.0.0-beta.31
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 +45 -2
- package/dist/esm/index.d.ts +1 -7
- package/dist/esm/index.js +1 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/light-account/accounts/base.js +0 -1
- package/dist/esm/light-account/accounts/base.js.map +1 -1
- package/dist/esm/light-account/accounts/calldataCodec.js +0 -3
- package/dist/esm/light-account/accounts/calldataCodec.js.map +1 -1
- package/dist/esm/light-account/utils.js +0 -5
- package/dist/esm/light-account/utils.js.map +1 -1
- package/dist/esm/ma-v1/accounts/base.js +1 -1
- package/dist/esm/ma-v1/accounts/base.js.map +1 -1
- package/dist/esm/ma-v1/accounts/calldataCodec.js +0 -4
- package/dist/esm/ma-v1/accounts/calldataCodec.js.map +1 -1
- package/dist/esm/ma-v1/mav1StaticImpl.d.ts +0 -2
- package/dist/esm/ma-v1/mav1StaticImpl.js +0 -2
- package/dist/esm/ma-v1/mav1StaticImpl.js.map +1 -1
- package/dist/esm/ma-v2/accounts/account.d.ts +39 -0
- package/dist/esm/ma-v2/accounts/account.js +40 -1
- package/dist/esm/ma-v2/accounts/account.js.map +1 -1
- package/dist/esm/ma-v2/accounts/base.js +1 -1
- package/dist/esm/ma-v2/accounts/base.js.map +1 -1
- package/dist/esm/ma-v2/accounts/calldataCodec.js +0 -4
- package/dist/esm/ma-v2/accounts/calldataCodec.js.map +1 -1
- package/dist/esm/ma-v2/decorators/deferralActions.d.ts +3 -3
- package/dist/esm/ma-v2/decorators/deferralActions.js +3 -3
- package/dist/esm/ma-v2/decorators/deferralActions.js.map +1 -1
- package/dist/esm/ma-v2/decorators/installValidation.d.ts +8 -20
- package/dist/esm/ma-v2/decorators/installValidation.js +7 -58
- package/dist/esm/ma-v2/decorators/installValidation.js.map +1 -1
- package/dist/esm/ma-v2/mav2StaticImpl.d.ts +0 -4
- package/dist/esm/ma-v2/mav2StaticImpl.js +0 -4
- package/dist/esm/ma-v2/mav2StaticImpl.js.map +1 -1
- package/dist/esm/ma-v2/permissionBuilder.d.ts +2 -2
- package/dist/esm/ma-v2/permissionBuilder.js +46 -14
- package/dist/esm/ma-v2/permissionBuilder.js.map +1 -1
- package/dist/esm/ma-v2/utils/account.js +0 -2
- package/dist/esm/ma-v2/utils/account.js.map +1 -1
- package/dist/esm/ma-v2/utils/deferredActions.d.ts +6 -6
- package/dist/esm/ma-v2/utils/deferredActions.js +5 -5
- package/dist/esm/ma-v2/utils/deferredActions.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/index.d.ts +1 -7
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/light-account/accounts/base.d.ts.map +1 -1
- package/dist/types/light-account/accounts/calldataCodec.d.ts.map +1 -1
- package/dist/types/light-account/utils.d.ts.map +1 -1
- package/dist/types/ma-v1/accounts/calldataCodec.d.ts.map +1 -1
- package/dist/types/ma-v1/mav1StaticImpl.d.ts +0 -2
- package/dist/types/ma-v1/mav1StaticImpl.d.ts.map +1 -1
- package/dist/types/ma-v2/accounts/account.d.ts +39 -0
- package/dist/types/ma-v2/accounts/account.d.ts.map +1 -1
- package/dist/types/ma-v2/accounts/calldataCodec.d.ts.map +1 -1
- package/dist/types/ma-v2/decorators/deferralActions.d.ts +3 -3
- package/dist/types/ma-v2/decorators/deferralActions.d.ts.map +1 -1
- package/dist/types/ma-v2/decorators/installValidation.d.ts +8 -20
- package/dist/types/ma-v2/decorators/installValidation.d.ts.map +1 -1
- package/dist/types/ma-v2/mav2StaticImpl.d.ts +0 -4
- package/dist/types/ma-v2/mav2StaticImpl.d.ts.map +1 -1
- package/dist/types/ma-v2/permissionBuilder.d.ts +2 -2
- package/dist/types/ma-v2/permissionBuilder.d.ts.map +1 -1
- package/dist/types/ma-v2/utils/account.d.ts.map +1 -1
- package/dist/types/ma-v2/utils/deferredActions.d.ts +6 -6
- package/dist/types/ma-v2/utils/deferredActions.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/index.ts +1 -14
- package/src/light-account/accounts/base.ts +0 -1
- package/src/light-account/accounts/calldataCodec.ts +0 -4
- package/src/light-account/utils.ts +0 -6
- package/src/ma-v1/accounts/base.ts +1 -1
- package/src/ma-v1/accounts/calldataCodec.ts +0 -5
- package/src/ma-v1/mav1StaticImpl.ts +0 -2
- package/src/ma-v2/accounts/account.ts +41 -2
- package/src/ma-v2/accounts/base.ts +1 -1
- package/src/ma-v2/accounts/calldataCodec.ts +0 -5
- package/src/ma-v2/decorators/deferralActions.ts +7 -7
- package/src/ma-v2/decorators/installValidation.ts +8 -83
- package/src/ma-v2/mav2StaticImpl.ts +0 -4
- package/src/ma-v2/permissionBuilder.ts +54 -17
- package/src/ma-v2/utils/account.ts +0 -2
- package/src/ma-v2/utils/deferredActions.ts +9 -9
- package/src/version.ts +1 -1
- package/dist/esm/light-account/decorators/multiOwner.d.ts +0 -17
- package/dist/esm/light-account/decorators/multiOwner.js +0 -39
- package/dist/esm/light-account/decorators/multiOwner.js.map +0 -1
- package/dist/esm/light-account/decorators/singleOwner.d.ts +0 -16
- package/dist/esm/light-account/decorators/singleOwner.js +0 -35
- package/dist/esm/light-account/decorators/singleOwner.js.map +0 -1
- package/dist/esm/ma-v1/decorators/multiOwner.d.ts +0 -17
- package/dist/esm/ma-v1/decorators/multiOwner.js +0 -39
- package/dist/esm/ma-v1/decorators/multiOwner.js.map +0 -1
- package/dist/types/light-account/decorators/multiOwner.d.ts +0 -18
- package/dist/types/light-account/decorators/multiOwner.d.ts.map +0 -1
- package/dist/types/light-account/decorators/singleOwner.d.ts +0 -17
- package/dist/types/light-account/decorators/singleOwner.d.ts.map +0 -1
- package/dist/types/ma-v1/decorators/multiOwner.d.ts +0 -18
- package/dist/types/ma-v1/decorators/multiOwner.d.ts.map +0 -1
- package/src/light-account/decorators/multiOwner.ts +0 -72
- package/src/light-account/decorators/singleOwner.ts +0 -63
- package/src/ma-v1/decorators/multiOwner.ts +0 -72
|
@@ -13,8 +13,7 @@ import type { HookConfig, ValidationConfig } from "../types.js";
|
|
|
13
13
|
import type { ModularAccountV2 } from "../accounts/account.js";
|
|
14
14
|
import type { GetAccountParameter } from "../../types.js";
|
|
15
15
|
import { semiModularAccountBytecodeAbi } from "../abis/semiModularAccountBytecodeAbi.js";
|
|
16
|
-
import {
|
|
17
|
-
import { getAction } from "viem/utils";
|
|
16
|
+
import type { SmartAccount } from "viem/account-abstraction";
|
|
18
17
|
import { AccountNotFoundError } from "@alchemy/common";
|
|
19
18
|
import { EntityIdOverrideError } from "../../errors/EntityIdOverrideError.js";
|
|
20
19
|
import {
|
|
@@ -54,33 +53,26 @@ export type InstallValidationActions<
|
|
|
54
53
|
encodeInstallValidation: (
|
|
55
54
|
args: InstallValidationParams<TAccount>,
|
|
56
55
|
) => Promise<Hex>;
|
|
57
|
-
installValidation: (args: InstallValidationParams<TAccount>) => Promise<Hex>;
|
|
58
56
|
encodeUninstallValidation: (
|
|
59
57
|
args: UninstallValidationParams<TAccount>,
|
|
60
58
|
) => Promise<Hex>;
|
|
61
|
-
uninstallValidation: (
|
|
62
|
-
args: UninstallValidationParams<TAccount>,
|
|
63
|
-
) => Promise<Hex>;
|
|
64
59
|
};
|
|
65
60
|
|
|
66
|
-
// TODO(v5): update jsdoc
|
|
67
61
|
/**
|
|
68
|
-
* Provides validation installation and uninstallation functionalities for a MA v2 client
|
|
62
|
+
* Provides validation installation and uninstallation encoding functionalities for a MA v2 client.
|
|
69
63
|
*
|
|
70
64
|
* @example
|
|
71
65
|
* ```ts
|
|
72
|
-
* import {
|
|
66
|
+
* import { installValidationActions, SingleSignerValidationModule } from "@alchemy/smart-accounts";
|
|
73
67
|
* import { Address } from "viem";
|
|
74
68
|
*
|
|
75
69
|
* const client = (await createModularAccountV2Client({ ... })).extend(installValidationActions);
|
|
76
70
|
* const sessionKeyAddress: Address = "0x1234";
|
|
77
71
|
* const sessionKeyEntityId: number = 1;
|
|
78
72
|
*
|
|
79
|
-
* await client.
|
|
73
|
+
* const callData = await client.encodeInstallValidation({
|
|
80
74
|
* validationConfig: {
|
|
81
|
-
* moduleAddress: getDefaultSingleSignerValidationModuleAddress(
|
|
82
|
-
* client.chain
|
|
83
|
-
* ),
|
|
75
|
+
* moduleAddress: getDefaultSingleSignerValidationModuleAddress(client.chain),
|
|
84
76
|
* entityId: sessionKeyEntityId,
|
|
85
77
|
* isGlobal: true,
|
|
86
78
|
* isSignatureValidation: false,
|
|
@@ -94,19 +86,11 @@ export type InstallValidationActions<
|
|
|
94
86
|
* hooks: [],
|
|
95
87
|
* });
|
|
96
88
|
*
|
|
97
|
-
* await client.
|
|
98
|
-
* moduleAddress: sessionKeyAddress,
|
|
99
|
-
* entityId: sessionKeyEntityId,
|
|
100
|
-
* uninstallData: SingleSignerValidationModule.encodeOnUninstallData({
|
|
101
|
-
* entityId: sessionKeyEntityId,
|
|
102
|
-
* }),
|
|
103
|
-
* hookUninstallDatas: [],
|
|
104
|
-
* });
|
|
105
|
-
*
|
|
89
|
+
* await client.sendUserOperation({ callData, account });
|
|
106
90
|
* ```
|
|
107
91
|
*
|
|
108
|
-
* @param {object} client - The client instance which provides account
|
|
109
|
-
* @returns {object} - An object containing
|
|
92
|
+
* @param {object} client - The client instance which provides account functionality.
|
|
93
|
+
* @returns {object} - An object containing `encodeInstallValidation` and `encodeUninstallValidation`.
|
|
110
94
|
*/
|
|
111
95
|
export function installValidationActions<
|
|
112
96
|
TTransport extends Transport = Transport,
|
|
@@ -194,64 +178,5 @@ export function installValidationActions<
|
|
|
194
178
|
return {
|
|
195
179
|
encodeInstallValidation,
|
|
196
180
|
encodeUninstallValidation,
|
|
197
|
-
installValidation: async (args) => {
|
|
198
|
-
const {
|
|
199
|
-
validationConfig,
|
|
200
|
-
selectors,
|
|
201
|
-
installData,
|
|
202
|
-
hooks,
|
|
203
|
-
account = client.account,
|
|
204
|
-
} = args;
|
|
205
|
-
|
|
206
|
-
if (!account || !isModularAccountV2(account)) {
|
|
207
|
-
throw new AccountNotFoundError();
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
const callData = await encodeInstallValidation({
|
|
211
|
-
validationConfig,
|
|
212
|
-
selectors,
|
|
213
|
-
installData,
|
|
214
|
-
hooks,
|
|
215
|
-
account,
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
const action = getAction(client, sendUserOperation, "sendUserOperation");
|
|
219
|
-
const result = await action({
|
|
220
|
-
callData,
|
|
221
|
-
account,
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
return result;
|
|
225
|
-
},
|
|
226
|
-
|
|
227
|
-
uninstallValidation: async (args) => {
|
|
228
|
-
const {
|
|
229
|
-
moduleAddress,
|
|
230
|
-
entityId,
|
|
231
|
-
uninstallData,
|
|
232
|
-
hookUninstallDatas,
|
|
233
|
-
account = client.account,
|
|
234
|
-
} = args;
|
|
235
|
-
|
|
236
|
-
if (!account || !isModularAccountV2(account)) {
|
|
237
|
-
throw new AccountNotFoundError();
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
const callData = await encodeUninstallValidation({
|
|
241
|
-
moduleAddress,
|
|
242
|
-
entityId,
|
|
243
|
-
uninstallData,
|
|
244
|
-
hookUninstallDatas,
|
|
245
|
-
account,
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
const action = getAction(client, sendUserOperation, "sendUserOperation");
|
|
249
|
-
const result = await action({
|
|
250
|
-
callData,
|
|
251
|
-
account,
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
return result;
|
|
255
|
-
},
|
|
256
181
|
};
|
|
257
182
|
}
|
|
@@ -36,8 +36,6 @@ const semiModularAccountBase = {
|
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Static implementation logic for SemiModularAccountV2.
|
|
39
|
-
*
|
|
40
|
-
* TODO(v5): update JSDoc format when doc-gen supports structs or records.
|
|
41
39
|
*/
|
|
42
40
|
export const semiModularAccountV2StaticImpl: SemiModularAccountV2StaticImpl = {
|
|
43
41
|
...semiModularAccountBase,
|
|
@@ -73,8 +71,6 @@ export type SemiModularAccount7702StaticImpl = StaticSmartAccountImplementation<
|
|
|
73
71
|
|
|
74
72
|
/**
|
|
75
73
|
* Static implementation logic for SemiModularAccount7702.
|
|
76
|
-
*
|
|
77
|
-
* TODO(v5): update JSDoc format when doc-gen supports structs or records.
|
|
78
74
|
*/
|
|
79
75
|
export const semiModularAccount7702StaticImpl: SemiModularAccount7702StaticImpl =
|
|
80
76
|
{
|
|
@@ -44,6 +44,46 @@ const ERC20_APPROVE_SELECTOR = "0x095ea7b3";
|
|
|
44
44
|
const ERC20_TRANSFER_SELECTOR = "0xa9059cbb";
|
|
45
45
|
const ACCOUNT_EXECUTE_SELECTOR = "0xb61d27f6";
|
|
46
46
|
const ACCOUNT_EXECUTEBATCH_SELECTOR = "0x34fcd5be";
|
|
47
|
+
const ACCOUNT_PERFORM_CREATE_SELECTOR = "0x5998db5c";
|
|
48
|
+
const ACCOUNT_EXECUTE_WITH_RUNTIME_VALIDATION_SELECTOR = "0xf2680c0f";
|
|
49
|
+
const ACCOUNT_INSTALL_VALIDATION_SELECTOR = "0x1bbf564c";
|
|
50
|
+
const ACCOUNT_UNINSTALL_VALIDATION_SELECTOR = "0xb6b1ccfe";
|
|
51
|
+
const ACCOUNT_INSTALL_EXECUTION_SELECTOR = "0x1d37e7d6";
|
|
52
|
+
const ACCOUNT_UNINSTALL_EXECUTION_SELECTOR = "0x0b7cad71";
|
|
53
|
+
const ACCOUNT_UPGRADE_TO_AND_CALL_SELECTOR = "0x4f1ef286";
|
|
54
|
+
// Wrapped native functions that must not be added to a session key's selector allowlist.
|
|
55
|
+
const PRIVILEGED_SELECTORS: Record<string, string> = {
|
|
56
|
+
[ACCOUNT_PERFORM_CREATE_SELECTOR]: "performCreate",
|
|
57
|
+
[ACCOUNT_EXECUTE_WITH_RUNTIME_VALIDATION_SELECTOR]:
|
|
58
|
+
"executeWithRuntimeValidation",
|
|
59
|
+
[ACCOUNT_INSTALL_VALIDATION_SELECTOR]: "installValidation",
|
|
60
|
+
[ACCOUNT_UNINSTALL_VALIDATION_SELECTOR]: "uninstallValidation",
|
|
61
|
+
[ACCOUNT_INSTALL_EXECUTION_SELECTOR]: "installExecution",
|
|
62
|
+
[ACCOUNT_UNINSTALL_EXECUTION_SELECTOR]: "uninstallExecution",
|
|
63
|
+
[ACCOUNT_UPGRADE_TO_AND_CALL_SELECTOR]: "upgradeToAndCall",
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// Auto-added by translatePermissions when a PREVAL_ALLOWLIST hook exists.
|
|
67
|
+
// Blocked from manual addition to ensure they're only added with proper hook context.
|
|
68
|
+
const SYSTEM_MANAGED_SELECTORS: Record<string, string> = {
|
|
69
|
+
[ACCOUNT_EXECUTE_SELECTOR]: "execute",
|
|
70
|
+
[ACCOUNT_EXECUTEBATCH_SELECTOR]: "executeBatch",
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
function assertNotForbiddenSelector(selector: Hex): void {
|
|
74
|
+
const normalized = selector.toLowerCase();
|
|
75
|
+
const match =
|
|
76
|
+
PRIVILEGED_SELECTORS[normalized] ?? SYSTEM_MANAGED_SELECTORS[normalized];
|
|
77
|
+
if (match != null) {
|
|
78
|
+
throw new SelectorNotAllowed(match);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function assertNoForbiddenSelectors(selectors: Hex[]): void {
|
|
83
|
+
for (const selector of selectors) {
|
|
84
|
+
assertNotForbiddenSelector(selector);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
47
87
|
|
|
48
88
|
/**
|
|
49
89
|
* A pseudo-enum for permission types.
|
|
@@ -277,7 +317,10 @@ export class PermissionBuilder {
|
|
|
277
317
|
signer: key.publicKey,
|
|
278
318
|
});
|
|
279
319
|
this.nonce = nonce;
|
|
280
|
-
if (selectors)
|
|
320
|
+
if (selectors) {
|
|
321
|
+
assertNoForbiddenSelectors(selectors);
|
|
322
|
+
this.selectors = selectors;
|
|
323
|
+
}
|
|
281
324
|
if (hooks) this.hooks = hooks;
|
|
282
325
|
if (deadline) this.deadline = deadline;
|
|
283
326
|
}
|
|
@@ -289,6 +332,7 @@ export class PermissionBuilder {
|
|
|
289
332
|
* @returns {this} The permission builder instance.
|
|
290
333
|
*/
|
|
291
334
|
addSelector({ selector }: { selector: Hex }): this {
|
|
335
|
+
assertNotForbiddenSelector(selector);
|
|
292
336
|
this.selectors.push(selector);
|
|
293
337
|
return this;
|
|
294
338
|
}
|
|
@@ -351,14 +395,7 @@ export class PermissionBuilder {
|
|
|
351
395
|
if (permission.data.functions.length === 0) {
|
|
352
396
|
throw new NoFunctionsProvidedError(permission);
|
|
353
397
|
}
|
|
354
|
-
|
|
355
|
-
if (permission.data.functions.includes(ACCOUNT_EXECUTE_SELECTOR)) {
|
|
356
|
-
throw new SelectorNotAllowed("execute");
|
|
357
|
-
} else if (
|
|
358
|
-
permission.data.functions.includes(ACCOUNT_EXECUTEBATCH_SELECTOR)
|
|
359
|
-
) {
|
|
360
|
-
throw new SelectorNotAllowed("executeBatch");
|
|
361
|
-
}
|
|
398
|
+
assertNoForbiddenSelectors(permission.data.functions);
|
|
362
399
|
this.selectors = [...this.selectors, ...permission.data.functions];
|
|
363
400
|
}
|
|
364
401
|
|
|
@@ -384,11 +421,11 @@ export class PermissionBuilder {
|
|
|
384
421
|
/**
|
|
385
422
|
* Compiles the deferred action typed data to sign.
|
|
386
423
|
*
|
|
387
|
-
* @returns {Promise<{typedData: DeferredActionTypedData,
|
|
424
|
+
* @returns {Promise<{typedData: DeferredActionTypedData, fullPreSignatureDeferredActionPayload: Hex}>} The deferred action typed data and the full pre-signature deferred action payload.
|
|
388
425
|
*/
|
|
389
426
|
async compileDeferred(): Promise<{
|
|
390
427
|
typedData: DeferredActionTypedData;
|
|
391
|
-
|
|
428
|
+
fullPreSignatureDeferredActionPayload: Hex;
|
|
392
429
|
}> {
|
|
393
430
|
// Add time range module hook via expiry
|
|
394
431
|
if (this.deadline !== 0) {
|
|
@@ -421,20 +458,20 @@ export class PermissionBuilder {
|
|
|
421
458
|
nonce: this.nonce,
|
|
422
459
|
});
|
|
423
460
|
|
|
424
|
-
const
|
|
461
|
+
const preSignaturePayload = deferralActions(
|
|
425
462
|
this.client,
|
|
426
|
-
).
|
|
463
|
+
).buildPreSignatureDeferredActionPayload({ typedData });
|
|
427
464
|
|
|
428
|
-
// Encode additional information to build the full pre-signature
|
|
429
|
-
const
|
|
465
|
+
// Encode additional information to build the full pre-signature payload
|
|
466
|
+
const fullPreSignatureDeferredActionPayload: `0x${string}` = `0x0${
|
|
430
467
|
this.hasAssociatedExecHooks ? "1" : "0"
|
|
431
468
|
}${toHex(this.nonce, {
|
|
432
469
|
size: 32,
|
|
433
|
-
}).slice(2)}${
|
|
470
|
+
}).slice(2)}${preSignaturePayload.slice(2)}`;
|
|
434
471
|
|
|
435
472
|
return {
|
|
436
473
|
typedData,
|
|
437
|
-
|
|
474
|
+
fullPreSignatureDeferredActionPayload,
|
|
438
475
|
};
|
|
439
476
|
}
|
|
440
477
|
|
|
@@ -64,8 +64,6 @@ export async function getMAV2UpgradeToData(
|
|
|
64
64
|
return {
|
|
65
65
|
implAddress: DefaultAddress.SMAV2_STORAGE,
|
|
66
66
|
initializationData: initData,
|
|
67
|
-
// TODO(v5): do we need `createModularAccountV2FromExisting()` in the return type here like we had in v4 or no?
|
|
68
|
-
// Almost certainly not, but we need to clean up other parts in SDK for client-side upgrades.
|
|
69
67
|
};
|
|
70
68
|
}
|
|
71
69
|
|
|
@@ -34,31 +34,31 @@ export const parseDeferredAction = (
|
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
export type
|
|
38
|
-
|
|
37
|
+
export type EncodeDeferredActionWithSignatureParams = {
|
|
38
|
+
fullPreSignatureDeferredActionPayload: Hex;
|
|
39
39
|
sig: Hex;
|
|
40
40
|
signaturePrefix?: SignaturePrefix;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
44
|
+
* Encodes the deferred action with its signature, producing the payload to prepend to the userOp signature.
|
|
45
45
|
*
|
|
46
46
|
* Assumption: The client this extends is used to sign the typed data.
|
|
47
47
|
*
|
|
48
|
-
* @param {
|
|
49
|
-
* @returns {Hex} The encoded
|
|
48
|
+
* @param {EncodeDeferredActionWithSignatureParams} params - The parameters for encoding the deferred action with its signature.
|
|
49
|
+
* @returns {Hex} The encoded payload to be prepended to the userOp signature.
|
|
50
50
|
*/
|
|
51
|
-
export const
|
|
52
|
-
|
|
51
|
+
export const encodeDeferredActionWithSignature = ({
|
|
52
|
+
fullPreSignatureDeferredActionPayload,
|
|
53
53
|
sig,
|
|
54
|
-
}:
|
|
54
|
+
}: EncodeDeferredActionWithSignatureParams): Hex => {
|
|
55
55
|
// 6492 sigs don't work here.
|
|
56
56
|
const _sig = parseErc6492Signature(sig).signature;
|
|
57
57
|
|
|
58
58
|
const sigLength = size(_sig);
|
|
59
59
|
|
|
60
60
|
const encodedData = concatHex([
|
|
61
|
-
|
|
61
|
+
fullPreSignatureDeferredActionPayload,
|
|
62
62
|
toHex(sigLength, { size: 4 }),
|
|
63
63
|
_sig,
|
|
64
64
|
]);
|
package/src/version.ts
CHANGED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Address, Chain, Client, Hex, IsUndefined, Transport } from "viem";
|
|
2
|
-
import { type SmartAccount } from "viem/account-abstraction";
|
|
3
|
-
import type { GetAccountParameter } from "../../types.js";
|
|
4
|
-
import type { MultiOwnerLightAccount } from "../accounts/multi-owner-account.js";
|
|
5
|
-
export type MultiOwnerLightAccountActions<TAccount extends MultiOwnerLightAccount | undefined = MultiOwnerLightAccount | undefined> = {
|
|
6
|
-
updateOwners: (args: {
|
|
7
|
-
ownersToAdd: Address[];
|
|
8
|
-
ownersToRemove: Address[];
|
|
9
|
-
} & GetAccountParameter<TAccount, MultiOwnerLightAccount>) => Promise<Hex>;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Generates client actions for a multi-owner light account, including the ability to update owners.
|
|
13
|
-
*
|
|
14
|
-
* @param {Client<TTransport, TChain, TAccount>} client The client instance used to interact with the account
|
|
15
|
-
* @returns {MultiOwnerLightAccountActions<TAccount>} An object containing the client actions specifically for a multi-owner light account
|
|
16
|
-
*/
|
|
17
|
-
export declare function multiOwnerLightAccountActions<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartAccount | undefined = SmartAccount | undefined>(client: Client<TTransport, TChain, TAccount>): MultiOwnerLightAccountActions<IsUndefined<TAccount> extends true ? undefined : MultiOwnerLightAccount>;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { sendUserOperation } from "viem/account-abstraction";
|
|
2
|
-
import { getAction } from "viem/utils";
|
|
3
|
-
import { AccountNotFoundError } from "@alchemy/common";
|
|
4
|
-
function isMultiOwnerLightAccount(account) {
|
|
5
|
-
return ("smartAccountType" in account &&
|
|
6
|
-
account.smartAccountType === "MultiOwnerLightAccount");
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Generates client actions for a multi-owner light account, including the ability to update owners.
|
|
10
|
-
*
|
|
11
|
-
* @param {Client<TTransport, TChain, TAccount>} client The client instance used to interact with the account
|
|
12
|
-
* @returns {MultiOwnerLightAccountActions<TAccount>} An object containing the client actions specifically for a multi-owner light account
|
|
13
|
-
*/
|
|
14
|
-
export function multiOwnerLightAccountActions(client) {
|
|
15
|
-
return {
|
|
16
|
-
// TODO(v5): Another pattern I think we should consider deprecating for v5 - actions that
|
|
17
|
-
// implicitly do a sendUserOperation internally. These are non-composable with batching
|
|
18
|
-
// and have a number of other issues that are solved with viem writeContract.
|
|
19
|
-
updateOwners: async (args) => {
|
|
20
|
-
const { ownersToAdd, ownersToRemove, account = client.account } = args;
|
|
21
|
-
if (!account || !isMultiOwnerLightAccount(account)) {
|
|
22
|
-
throw new AccountNotFoundError();
|
|
23
|
-
}
|
|
24
|
-
const data = account.encodeUpdateOwners(ownersToAdd, ownersToRemove);
|
|
25
|
-
const action = getAction(client, sendUserOperation, "sendUserOperation");
|
|
26
|
-
const result = await action({
|
|
27
|
-
calls: [
|
|
28
|
-
{
|
|
29
|
-
to: account.address,
|
|
30
|
-
data,
|
|
31
|
-
},
|
|
32
|
-
],
|
|
33
|
-
account,
|
|
34
|
-
});
|
|
35
|
-
return result;
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=multiOwner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"multiOwner.js","sourceRoot":"","sources":["../../../../src/light-account/decorators/multiOwner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAqB,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAevD,SAAS,wBAAwB,CAC/B,OAAqB;IAErB,OAAO,CACL,kBAAkB,IAAI,OAAO;QAC7B,OAAO,CAAC,gBAAgB,KAAK,wBAAwB,CACtD,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAK3C,MAA4C;IAI5C,OAAO;QACL,yFAAyF;QACzF,uFAAuF;QACvF,6EAA6E;QAC7E,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YAC3B,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;YAEvE,IAAI,CAAC,OAAO,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,EAAE,CAAC;gBACnD,MAAM,IAAI,oBAAoB,EAAE,CAAC;YACnC,CAAC;YAED,MAAM,IAAI,GAAG,OAAO,CAAC,kBAAkB,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;YAErE,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;YACzE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC;gBAC1B,KAAK,EAAE;oBACL;wBACE,EAAE,EAAE,OAAO,CAAC,OAAO;wBACnB,IAAI;qBACL;iBACF;gBACD,OAAO;aACR,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { Address, Chain, Client, Hex, IsUndefined, Transport } from \"viem\";\nimport { sendUserOperation, type SmartAccount } from \"viem/account-abstraction\";\nimport { getAction } from \"viem/utils\";\nimport type { GetAccountParameter } from \"../../types.js\";\nimport type { MultiOwnerLightAccount } from \"../accounts/multi-owner-account.js\";\nimport { AccountNotFoundError } from \"@alchemy/common\";\n\nexport type MultiOwnerLightAccountActions<\n TAccount extends MultiOwnerLightAccount | undefined =\n | MultiOwnerLightAccount\n | undefined,\n> = {\n updateOwners: (\n args: {\n ownersToAdd: Address[];\n ownersToRemove: Address[];\n } & GetAccountParameter<TAccount, MultiOwnerLightAccount>,\n ) => Promise<Hex>;\n};\n\nfunction isMultiOwnerLightAccount(\n account: SmartAccount,\n): account is MultiOwnerLightAccount {\n return (\n \"smartAccountType\" in account &&\n account.smartAccountType === \"MultiOwnerLightAccount\"\n );\n}\n\n/**\n * Generates client actions for a multi-owner light account, including the ability to update owners.\n *\n * @param {Client<TTransport, TChain, TAccount>} client The client instance used to interact with the account\n * @returns {MultiOwnerLightAccountActions<TAccount>} An object containing the client actions specifically for a multi-owner light account\n */\nexport function multiOwnerLightAccountActions<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartAccount | undefined = SmartAccount | undefined,\n>(\n client: Client<TTransport, TChain, TAccount>,\n): MultiOwnerLightAccountActions<\n IsUndefined<TAccount> extends true ? undefined : MultiOwnerLightAccount\n> {\n return {\n // TODO(v5): Another pattern I think we should consider deprecating for v5 - actions that\n // implicitly do a sendUserOperation internally. These are non-composable with batching\n // and have a number of other issues that are solved with viem writeContract.\n updateOwners: async (args) => {\n const { ownersToAdd, ownersToRemove, account = client.account } = args;\n\n if (!account || !isMultiOwnerLightAccount(account)) {\n throw new AccountNotFoundError();\n }\n\n const data = account.encodeUpdateOwners(ownersToAdd, ownersToRemove);\n\n const action = getAction(client, sendUserOperation, \"sendUserOperation\");\n const result = await action({\n calls: [\n {\n to: account.address,\n data,\n },\n ],\n account,\n });\n\n return result;\n },\n };\n}\n"]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Address, Chain, Client, Hex, IsUndefined, Transport } from "viem";
|
|
2
|
-
import { type SmartAccount } from "viem/account-abstraction";
|
|
3
|
-
import type { GetAccountParameter } from "../../types.js";
|
|
4
|
-
import type { LightAccount } from "../accounts/account.js";
|
|
5
|
-
export type LightAccountActions<TAccount extends LightAccount | undefined = LightAccount | undefined> = {
|
|
6
|
-
transferOwnership: (args: {
|
|
7
|
-
newOwner: Address;
|
|
8
|
-
} & GetAccountParameter<TAccount, LightAccount>) => Promise<Hex>;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* A decorator that can be used with viem's bundler client to add light account actions to the client
|
|
12
|
-
*
|
|
13
|
-
* @param {BundlerClient<TTransport, TChain, TAccount>} client The client instance for which to provide the light account actions
|
|
14
|
-
* @returns {LightAccountActions<TAccount>} An object containing the available light account actions
|
|
15
|
-
*/
|
|
16
|
-
export declare function singleOwnerLightAccountActions<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartAccount | undefined = SmartAccount | undefined>(client: Client<TTransport, TChain, TAccount>): LightAccountActions<IsUndefined<TAccount> extends true ? undefined : LightAccount>;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { AccountNotFoundError } from "@alchemy/common";
|
|
2
|
-
import { sendUserOperation } from "viem/account-abstraction";
|
|
3
|
-
import { getAction } from "viem/utils";
|
|
4
|
-
function isLightAccount(account) {
|
|
5
|
-
return ("smartAccountType" in account && account.smartAccountType === "LightAccount");
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* A decorator that can be used with viem's bundler client to add light account actions to the client
|
|
9
|
-
*
|
|
10
|
-
* @param {BundlerClient<TTransport, TChain, TAccount>} client The client instance for which to provide the light account actions
|
|
11
|
-
* @returns {LightAccountActions<TAccount>} An object containing the available light account actions
|
|
12
|
-
*/
|
|
13
|
-
export function singleOwnerLightAccountActions(client) {
|
|
14
|
-
return {
|
|
15
|
-
transferOwnership: async (args) => {
|
|
16
|
-
const { newOwner, account = client.account } = args;
|
|
17
|
-
if (!account || !isLightAccount(account)) {
|
|
18
|
-
throw new AccountNotFoundError();
|
|
19
|
-
}
|
|
20
|
-
const data = account.encodeTransferOwnership(newOwner);
|
|
21
|
-
const action = getAction(client, sendUserOperation, "sendUserOperation");
|
|
22
|
-
const result = await action({
|
|
23
|
-
calls: [
|
|
24
|
-
{
|
|
25
|
-
to: account.address,
|
|
26
|
-
data,
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
account,
|
|
30
|
-
});
|
|
31
|
-
return result;
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=singleOwner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"singleOwner.js","sourceRoot":"","sources":["../../../../src/light-account/decorators/singleOwner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAqB,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAcvC,SAAS,cAAc,CAAC,OAAqB;IAC3C,OAAO,CACL,kBAAkB,IAAI,OAAO,IAAI,OAAO,CAAC,gBAAgB,KAAK,cAAc,CAC7E,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B,CAK5C,MAA4C;IAI5C,OAAO;QACL,iBAAiB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YAChC,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;YAEpD,IAAI,CAAC,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;gBACzC,MAAM,IAAI,oBAAoB,EAAE,CAAC;YACnC,CAAC;YAED,MAAM,IAAI,GAAG,OAAO,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC;YAEvD,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;YACzE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC;gBAC1B,KAAK,EAAE;oBACL;wBACE,EAAE,EAAE,OAAO,CAAC,OAAO;wBACnB,IAAI;qBACL;iBACF;gBACD,OAAO;aACR,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { AccountNotFoundError } from \"@alchemy/common\";\nimport type { Address, Chain, Client, Hex, IsUndefined, Transport } from \"viem\";\nimport { sendUserOperation, type SmartAccount } from \"viem/account-abstraction\";\nimport { getAction } from \"viem/utils\";\nimport type { GetAccountParameter } from \"../../types.js\";\nimport type { LightAccount } from \"../accounts/account.js\";\n\nexport type LightAccountActions<\n TAccount extends LightAccount | undefined = LightAccount | undefined,\n> = {\n transferOwnership: (\n args: {\n newOwner: Address;\n } & GetAccountParameter<TAccount, LightAccount>,\n ) => Promise<Hex>;\n};\n\nfunction isLightAccount(account: SmartAccount): account is LightAccount {\n return (\n \"smartAccountType\" in account && account.smartAccountType === \"LightAccount\"\n );\n}\n\n/**\n * A decorator that can be used with viem's bundler client to add light account actions to the client\n *\n * @param {BundlerClient<TTransport, TChain, TAccount>} client The client instance for which to provide the light account actions\n * @returns {LightAccountActions<TAccount>} An object containing the available light account actions\n */\nexport function singleOwnerLightAccountActions<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartAccount | undefined = SmartAccount | undefined,\n>(\n client: Client<TTransport, TChain, TAccount>,\n): LightAccountActions<\n IsUndefined<TAccount> extends true ? undefined : LightAccount\n> {\n return {\n transferOwnership: async (args) => {\n const { newOwner, account = client.account } = args;\n\n if (!account || !isLightAccount(account)) {\n throw new AccountNotFoundError();\n }\n\n const data = account.encodeTransferOwnership(newOwner);\n\n const action = getAction(client, sendUserOperation, \"sendUserOperation\");\n const result = await action({\n calls: [\n {\n to: account.address,\n data,\n },\n ],\n account,\n });\n\n return result;\n },\n };\n}\n"]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Address, Chain, Client, Hex, IsUndefined, Transport } from "viem";
|
|
2
|
-
import { type SmartAccount } from "viem/account-abstraction";
|
|
3
|
-
import type { GetAccountParameter } from "../../types.js";
|
|
4
|
-
import type { MultiOwnerModularAccountV1 } from "../accounts/multi-owner-account.js";
|
|
5
|
-
export type MultiOwnerModularAccountV1Actions<TAccount extends MultiOwnerModularAccountV1 | undefined = MultiOwnerModularAccountV1 | undefined> = {
|
|
6
|
-
updateOwners: (args: {
|
|
7
|
-
ownersToAdd: Address[];
|
|
8
|
-
ownersToRemove: Address[];
|
|
9
|
-
} & GetAccountParameter<TAccount, MultiOwnerModularAccountV1>) => Promise<Hex>;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Generates client actions for a multi-owner MAv1 account, including the ability to update owners.
|
|
13
|
-
*
|
|
14
|
-
* @param {Client<TTransport, TChain, TAccount>} client The client instance used to interact with the account
|
|
15
|
-
* @returns {MultiOwnerLightAccountActions<TAccount>} An object containing the client actions specifically for a multi-owner modular account
|
|
16
|
-
*/
|
|
17
|
-
export declare function multiOwnerModularAccountV1Actions<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartAccount | undefined = SmartAccount | undefined>(client: Client<TTransport, TChain, TAccount>): MultiOwnerModularAccountV1Actions<IsUndefined<TAccount> extends true ? undefined : MultiOwnerModularAccountV1>;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { sendUserOperation } from "viem/account-abstraction";
|
|
2
|
-
import { getAction } from "viem/utils";
|
|
3
|
-
import { AccountNotFoundError } from "@alchemy/common";
|
|
4
|
-
function isMultiOwnerModularAccountV1(account) {
|
|
5
|
-
return ("smartAccountType" in account &&
|
|
6
|
-
account.smartAccountType === "MultiOwnerModularAccountV1");
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Generates client actions for a multi-owner MAv1 account, including the ability to update owners.
|
|
10
|
-
*
|
|
11
|
-
* @param {Client<TTransport, TChain, TAccount>} client The client instance used to interact with the account
|
|
12
|
-
* @returns {MultiOwnerLightAccountActions<TAccount>} An object containing the client actions specifically for a multi-owner modular account
|
|
13
|
-
*/
|
|
14
|
-
export function multiOwnerModularAccountV1Actions(client) {
|
|
15
|
-
return {
|
|
16
|
-
// TODO(v5): Another pattern I think we should consider deprecating for v5 - actions that
|
|
17
|
-
// implicitly do a sendUserOperation internally. These are non-composable with batching
|
|
18
|
-
// and have a number of other issues that are solved with viem writeContract.
|
|
19
|
-
updateOwners: async (args) => {
|
|
20
|
-
const { ownersToAdd, ownersToRemove, account = client.account } = args;
|
|
21
|
-
if (!account || !isMultiOwnerModularAccountV1(account)) {
|
|
22
|
-
throw new AccountNotFoundError();
|
|
23
|
-
}
|
|
24
|
-
const data = account.encodeUpdateOwners(ownersToAdd, ownersToRemove);
|
|
25
|
-
const action = getAction(client, sendUserOperation, "sendUserOperation");
|
|
26
|
-
const result = await action({
|
|
27
|
-
calls: [
|
|
28
|
-
{
|
|
29
|
-
to: account.address,
|
|
30
|
-
data,
|
|
31
|
-
},
|
|
32
|
-
],
|
|
33
|
-
account,
|
|
34
|
-
});
|
|
35
|
-
return result;
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=multiOwner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"multiOwner.js","sourceRoot":"","sources":["../../../../src/ma-v1/decorators/multiOwner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAqB,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAgBvD,SAAS,4BAA4B,CACnC,OAAqB;IAErB,OAAO,CACL,kBAAkB,IAAI,OAAO;QAC7B,OAAO,CAAC,gBAAgB,KAAK,4BAA4B,CAC1D,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iCAAiC,CAK/C,MAA4C;IAI5C,OAAO;QACL,yFAAyF;QACzF,uFAAuF;QACvF,6EAA6E;QAC7E,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YAC3B,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;YAEvE,IAAI,CAAC,OAAO,IAAI,CAAC,4BAA4B,CAAC,OAAO,CAAC,EAAE,CAAC;gBACvD,MAAM,IAAI,oBAAoB,EAAE,CAAC;YACnC,CAAC;YAED,MAAM,IAAI,GAAG,OAAO,CAAC,kBAAkB,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;YAErE,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;YACzE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC;gBAC1B,KAAK,EAAE;oBACL;wBACE,EAAE,EAAE,OAAO,CAAC,OAAO;wBACnB,IAAI;qBACL;iBACF;gBACD,OAAO;aACR,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { Address, Chain, Client, Hex, IsUndefined, Transport } from \"viem\";\nimport { sendUserOperation, type SmartAccount } from \"viem/account-abstraction\";\nimport { getAction } from \"viem/utils\";\nimport type { GetAccountParameter } from \"../../types.js\";\nimport { AccountNotFoundError } from \"@alchemy/common\";\nimport type { MultiOwnerModularAccountV1 } from \"../accounts/multi-owner-account.js\";\n\nexport type MultiOwnerModularAccountV1Actions<\n TAccount extends MultiOwnerModularAccountV1 | undefined =\n | MultiOwnerModularAccountV1\n | undefined,\n> = {\n updateOwners: (\n args: {\n ownersToAdd: Address[];\n ownersToRemove: Address[];\n } & GetAccountParameter<TAccount, MultiOwnerModularAccountV1>,\n ) => Promise<Hex>;\n};\n\nfunction isMultiOwnerModularAccountV1(\n account: SmartAccount,\n): account is MultiOwnerModularAccountV1 {\n return (\n \"smartAccountType\" in account &&\n account.smartAccountType === \"MultiOwnerModularAccountV1\"\n );\n}\n\n/**\n * Generates client actions for a multi-owner MAv1 account, including the ability to update owners.\n *\n * @param {Client<TTransport, TChain, TAccount>} client The client instance used to interact with the account\n * @returns {MultiOwnerLightAccountActions<TAccount>} An object containing the client actions specifically for a multi-owner modular account\n */\nexport function multiOwnerModularAccountV1Actions<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartAccount | undefined = SmartAccount | undefined,\n>(\n client: Client<TTransport, TChain, TAccount>,\n): MultiOwnerModularAccountV1Actions<\n IsUndefined<TAccount> extends true ? undefined : MultiOwnerModularAccountV1\n> {\n return {\n // TODO(v5): Another pattern I think we should consider deprecating for v5 - actions that\n // implicitly do a sendUserOperation internally. These are non-composable with batching\n // and have a number of other issues that are solved with viem writeContract.\n updateOwners: async (args) => {\n const { ownersToAdd, ownersToRemove, account = client.account } = args;\n\n if (!account || !isMultiOwnerModularAccountV1(account)) {\n throw new AccountNotFoundError();\n }\n\n const data = account.encodeUpdateOwners(ownersToAdd, ownersToRemove);\n\n const action = getAction(client, sendUserOperation, \"sendUserOperation\");\n const result = await action({\n calls: [\n {\n to: account.address,\n data,\n },\n ],\n account,\n });\n\n return result;\n },\n };\n}\n"]}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Address, Chain, Client, Hex, IsUndefined, Transport } from "viem";
|
|
2
|
-
import { type SmartAccount } from "viem/account-abstraction";
|
|
3
|
-
import type { GetAccountParameter } from "../../types.js";
|
|
4
|
-
import type { MultiOwnerLightAccount } from "../accounts/multi-owner-account.js";
|
|
5
|
-
export type MultiOwnerLightAccountActions<TAccount extends MultiOwnerLightAccount | undefined = MultiOwnerLightAccount | undefined> = {
|
|
6
|
-
updateOwners: (args: {
|
|
7
|
-
ownersToAdd: Address[];
|
|
8
|
-
ownersToRemove: Address[];
|
|
9
|
-
} & GetAccountParameter<TAccount, MultiOwnerLightAccount>) => Promise<Hex>;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Generates client actions for a multi-owner light account, including the ability to update owners.
|
|
13
|
-
*
|
|
14
|
-
* @param {Client<TTransport, TChain, TAccount>} client The client instance used to interact with the account
|
|
15
|
-
* @returns {MultiOwnerLightAccountActions<TAccount>} An object containing the client actions specifically for a multi-owner light account
|
|
16
|
-
*/
|
|
17
|
-
export declare function multiOwnerLightAccountActions<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartAccount | undefined = SmartAccount | undefined>(client: Client<TTransport, TChain, TAccount>): MultiOwnerLightAccountActions<IsUndefined<TAccount> extends true ? undefined : MultiOwnerLightAccount>;
|
|
18
|
-
//# sourceMappingURL=multiOwner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"multiOwner.d.ts","sourceRoot":"","sources":["../../../../src/light-account/decorators/multiOwner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAChF,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEhF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAGjF,MAAM,MAAM,6BAA6B,CACvC,QAAQ,SAAS,sBAAsB,GAAG,SAAS,GAC/C,sBAAsB,GACtB,SAAS,IACX;IACF,YAAY,EAAE,CACZ,IAAI,EAAE;QACJ,WAAW,EAAE,OAAO,EAAE,CAAC;QACvB,cAAc,EAAE,OAAO,EAAE,CAAC;KAC3B,GAAG,mBAAmB,CAAC,QAAQ,EAAE,sBAAsB,CAAC,KACtD,OAAO,CAAC,GAAG,CAAC,CAAC;CACnB,CAAC;AAWF;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,UAAU,SAAS,SAAS,GAAG,SAAS,EACxC,MAAM,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EACpD,QAAQ,SAAS,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,EAEpE,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,GAC3C,6BAA6B,CAC9B,WAAW,CAAC,QAAQ,CAAC,SAAS,IAAI,GAAG,SAAS,GAAG,sBAAsB,CACxE,CA4BA"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Address, Chain, Client, Hex, IsUndefined, Transport } from "viem";
|
|
2
|
-
import { type SmartAccount } from "viem/account-abstraction";
|
|
3
|
-
import type { GetAccountParameter } from "../../types.js";
|
|
4
|
-
import type { LightAccount } from "../accounts/account.js";
|
|
5
|
-
export type LightAccountActions<TAccount extends LightAccount | undefined = LightAccount | undefined> = {
|
|
6
|
-
transferOwnership: (args: {
|
|
7
|
-
newOwner: Address;
|
|
8
|
-
} & GetAccountParameter<TAccount, LightAccount>) => Promise<Hex>;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* A decorator that can be used with viem's bundler client to add light account actions to the client
|
|
12
|
-
*
|
|
13
|
-
* @param {BundlerClient<TTransport, TChain, TAccount>} client The client instance for which to provide the light account actions
|
|
14
|
-
* @returns {LightAccountActions<TAccount>} An object containing the available light account actions
|
|
15
|
-
*/
|
|
16
|
-
export declare function singleOwnerLightAccountActions<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartAccount | undefined = SmartAccount | undefined>(client: Client<TTransport, TChain, TAccount>): LightAccountActions<IsUndefined<TAccount> extends true ? undefined : LightAccount>;
|
|
17
|
-
//# sourceMappingURL=singleOwner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"singleOwner.d.ts","sourceRoot":"","sources":["../../../../src/light-account/decorators/singleOwner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAChF,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEhF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,MAAM,mBAAmB,CAC7B,QAAQ,SAAS,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,IAClE;IACF,iBAAiB,EAAE,CACjB,IAAI,EAAE;QACJ,QAAQ,EAAE,OAAO,CAAC;KACnB,GAAG,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,KAC5C,OAAO,CAAC,GAAG,CAAC,CAAC;CACnB,CAAC;AAQF;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC5C,UAAU,SAAS,SAAS,GAAG,SAAS,EACxC,MAAM,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EACpD,QAAQ,SAAS,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,EAEpE,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,GAC3C,mBAAmB,CACpB,WAAW,CAAC,QAAQ,CAAC,SAAS,IAAI,GAAG,SAAS,GAAG,YAAY,CAC9D,CAyBA"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Address, Chain, Client, Hex, IsUndefined, Transport } from "viem";
|
|
2
|
-
import { type SmartAccount } from "viem/account-abstraction";
|
|
3
|
-
import type { GetAccountParameter } from "../../types.js";
|
|
4
|
-
import type { MultiOwnerModularAccountV1 } from "../accounts/multi-owner-account.js";
|
|
5
|
-
export type MultiOwnerModularAccountV1Actions<TAccount extends MultiOwnerModularAccountV1 | undefined = MultiOwnerModularAccountV1 | undefined> = {
|
|
6
|
-
updateOwners: (args: {
|
|
7
|
-
ownersToAdd: Address[];
|
|
8
|
-
ownersToRemove: Address[];
|
|
9
|
-
} & GetAccountParameter<TAccount, MultiOwnerModularAccountV1>) => Promise<Hex>;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Generates client actions for a multi-owner MAv1 account, including the ability to update owners.
|
|
13
|
-
*
|
|
14
|
-
* @param {Client<TTransport, TChain, TAccount>} client The client instance used to interact with the account
|
|
15
|
-
* @returns {MultiOwnerLightAccountActions<TAccount>} An object containing the client actions specifically for a multi-owner modular account
|
|
16
|
-
*/
|
|
17
|
-
export declare function multiOwnerModularAccountV1Actions<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartAccount | undefined = SmartAccount | undefined>(client: Client<TTransport, TChain, TAccount>): MultiOwnerModularAccountV1Actions<IsUndefined<TAccount> extends true ? undefined : MultiOwnerModularAccountV1>;
|
|
18
|
-
//# sourceMappingURL=multiOwner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"multiOwner.d.ts","sourceRoot":"","sources":["../../../../src/ma-v1/decorators/multiOwner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAChF,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEhF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAErF,MAAM,MAAM,iCAAiC,CAC3C,QAAQ,SAAS,0BAA0B,GAAG,SAAS,GACnD,0BAA0B,GAC1B,SAAS,IACX;IACF,YAAY,EAAE,CACZ,IAAI,EAAE;QACJ,WAAW,EAAE,OAAO,EAAE,CAAC;QACvB,cAAc,EAAE,OAAO,EAAE,CAAC;KAC3B,GAAG,mBAAmB,CAAC,QAAQ,EAAE,0BAA0B,CAAC,KAC1D,OAAO,CAAC,GAAG,CAAC,CAAC;CACnB,CAAC;AAWF;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAC/C,UAAU,SAAS,SAAS,GAAG,SAAS,EACxC,MAAM,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EACpD,QAAQ,SAAS,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,EAEpE,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,GAC3C,iCAAiC,CAClC,WAAW,CAAC,QAAQ,CAAC,SAAS,IAAI,GAAG,SAAS,GAAG,0BAA0B,CAC5E,CA4BA"}
|