@metamask/smart-accounts-kit 1.3.0 → 1.5.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/CHANGELOG.md +20 -1
- package/dist/actions/index.cjs +8 -4
- package/dist/actions/index.cjs.map +1 -1
- package/dist/actions/index.d.cts +4 -2
- package/dist/actions/index.d.ts +4 -2
- package/dist/actions/index.mjs +7 -3
- package/dist/{caveats-Cey0wm33.d.cts → caveats-CaSt_VHs.d.cts} +1 -1
- package/dist/{caveats-CQbtzOKm.d.ts → caveats-DQ6HoAHe.d.ts} +1 -1
- package/dist/{chunk-GZ7HHI2D.cjs → chunk-7FYDQNJ3.cjs} +12 -12
- package/dist/{chunk-GZ7HHI2D.cjs.map → chunk-7FYDQNJ3.cjs.map} +1 -1
- package/dist/{chunk-FKI4OME5.mjs → chunk-BGOSYTKV.mjs} +254 -60
- package/dist/chunk-BGOSYTKV.mjs.map +1 -0
- package/dist/{chunk-57I2FJY7.cjs → chunk-DN4O5VOP.cjs} +102 -102
- package/dist/{chunk-57I2FJY7.cjs.map → chunk-DN4O5VOP.cjs.map} +1 -1
- package/dist/{chunk-DLCTHNAE.cjs → chunk-FH6HZCHI.cjs} +11 -11
- package/dist/{chunk-DLCTHNAE.cjs.map → chunk-FH6HZCHI.cjs.map} +1 -1
- package/dist/{chunk-SZOX7K2V.cjs → chunk-IBZSNB7D.cjs} +81 -33
- package/dist/chunk-IBZSNB7D.cjs.map +1 -0
- package/dist/{chunk-Z4D7ZWVB.mjs → chunk-MV2KHN75.mjs} +84 -36
- package/dist/chunk-MV2KHN75.mjs.map +1 -0
- package/dist/{chunk-AC2BQSYP.mjs → chunk-N66VAWMO.mjs} +2 -2
- package/dist/{chunk-3PBVHNYP.cjs → chunk-SCS3CFRE.cjs} +10 -10
- package/dist/{chunk-3PBVHNYP.cjs.map → chunk-SCS3CFRE.cjs.map} +1 -1
- package/dist/{chunk-26PADMXR.mjs → chunk-TBHT26BV.mjs} +4 -4
- package/dist/{chunk-KBSFVKUB.mjs → chunk-W7O2UQL5.mjs} +2 -2
- package/dist/{chunk-AJWMPR7X.cjs → chunk-XEOE25DE.cjs} +298 -104
- package/dist/chunk-XEOE25DE.cjs.map +1 -0
- package/dist/{chunk-LQXOM3TA.mjs → chunk-YXHUT56Z.mjs} +3 -3
- package/dist/contracts/index.cjs +5 -5
- package/dist/contracts/index.d.cts +3 -2
- package/dist/contracts/index.d.ts +3 -2
- package/dist/contracts/index.mjs +4 -4
- package/dist/delegation-BKkEyxZY.d.cts +64 -0
- package/dist/delegation-DbPGWKfP.d.ts +64 -0
- package/dist/experimental/index.cjs +7 -7
- package/dist/experimental/index.mjs +1 -1
- package/dist/{index-D2THBlfm.d.ts → index-DXdlz7t4.d.ts} +2 -1
- package/dist/{index-BDC55AA9.d.cts → index-DfDAuvr5.d.cts} +58 -5
- package/dist/{index-DhG2lH80.d.ts → index-G78z6nwi.d.ts} +58 -5
- package/dist/{index-DE87r5KY.d.cts → index-yU3olCJV.d.cts} +2 -1
- package/dist/index.cjs +22 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.mjs +9 -7
- package/dist/index.mjs.map +1 -1
- package/dist/{delegation-Bx4FEAIU.d.ts → resolveCaveats-DiqGB-T5.d.cts} +4 -57
- package/dist/{delegation-KbWHzRxV.d.cts → resolveCaveats-s2snaFEo.d.ts} +4 -57
- package/dist/utils/index.cjs +4 -4
- package/dist/utils/index.d.cts +3 -2
- package/dist/utils/index.d.ts +3 -2
- package/dist/utils/index.mjs +3 -3
- package/package.json +4 -4
- package/dist/chunk-AJWMPR7X.cjs.map +0 -1
- package/dist/chunk-FKI4OME5.mjs.map +0 -1
- package/dist/chunk-SZOX7K2V.cjs.map +0 -1
- package/dist/chunk-Z4D7ZWVB.mjs.map +0 -1
- /package/dist/{chunk-AC2BQSYP.mjs.map → chunk-N66VAWMO.mjs.map} +0 -0
- /package/dist/{chunk-26PADMXR.mjs.map → chunk-TBHT26BV.mjs.map} +0 -0
- /package/dist/{chunk-KBSFVKUB.mjs.map → chunk-W7O2UQL5.mjs.map} +0 -0
- /package/dist/{chunk-LQXOM3TA.mjs.map → chunk-YXHUT56Z.mjs.map} +0 -0
|
@@ -1,9 +1,33 @@
|
|
|
1
|
+
import { Account, Address, Hex, Chain, Client, Transport, WalletClient, RpcSchema, OneOf, SendTransactionRequest, SendTransactionParameters, PublicClient } from 'viem';
|
|
2
|
+
import { S as SmartAccountsEnvironment, P as PermissionContext, D as Delegation, l as Call } from './types-BWaH4KH1.cjs';
|
|
3
|
+
import { S as ScopeConfig, C as Caveats } from './resolveCaveats-DiqGB-T5.cjs';
|
|
1
4
|
import { Rule, PermissionRequest as PermissionRequest$1, PermissionTypes as PermissionTypes$1, PermissionResponse as PermissionResponse$1 } from '@metamask/7715-permission-types';
|
|
2
|
-
import { Address, Hex, Client, Transport, Chain, Account, RpcSchema, OneOf, PublicClient, SendTransactionRequest, SendTransactionParameters, WalletClient } from 'viem';
|
|
3
5
|
import { SmartAccount, SendUserOperationParameters } from 'viem/account-abstraction';
|
|
4
|
-
import { l as Call, P as PermissionContext, S as SmartAccountsEnvironment, D as Delegation } from './types-BWaH4KH1.cjs';
|
|
5
6
|
import { U as UserOperationV07 } from './userOp-DKgjzz7B.cjs';
|
|
6
7
|
|
|
8
|
+
type BaseRedelegatePermissionContextParameters = {
|
|
9
|
+
account?: Account | Address;
|
|
10
|
+
environment: SmartAccountsEnvironment;
|
|
11
|
+
permissionContext: PermissionContext;
|
|
12
|
+
chainId?: number;
|
|
13
|
+
scope?: ScopeConfig;
|
|
14
|
+
caveats?: Caveats;
|
|
15
|
+
salt?: Hex;
|
|
16
|
+
};
|
|
17
|
+
type RedelegatePermissionContextParameters = BaseRedelegatePermissionContextParameters & {
|
|
18
|
+
to: Address;
|
|
19
|
+
};
|
|
20
|
+
type RedelegatePermissionContextOpenParameters = BaseRedelegatePermissionContextParameters;
|
|
21
|
+
type RedelegatePermissionContextReturnType = {
|
|
22
|
+
delegation: Delegation;
|
|
23
|
+
permissionContext: Hex;
|
|
24
|
+
};
|
|
25
|
+
type SigningClient<TChain extends Chain | undefined, TAccount extends Account | undefined> = Client<Transport, TChain, TAccount> & {
|
|
26
|
+
signTypedData: WalletClient['signTypedData'];
|
|
27
|
+
};
|
|
28
|
+
declare function redelegatePermissionContextAction<TChain extends Chain | undefined, TAccount extends Account | undefined>(client: SigningClient<TChain, TAccount>, parameters: RedelegatePermissionContextParameters): Promise<RedelegatePermissionContextReturnType>;
|
|
29
|
+
declare function redelegatePermissionContextOpenAction<TChain extends Chain | undefined, TAccount extends Account | undefined>(client: SigningClient<TChain, TAccount>, parameters: RedelegatePermissionContextOpenParameters): Promise<RedelegatePermissionContextReturnType>;
|
|
30
|
+
|
|
7
31
|
type BasePermission = {
|
|
8
32
|
type: string;
|
|
9
33
|
isAdjustmentAllowed: boolean;
|
|
@@ -49,13 +73,30 @@ type Erc20TokenPeriodicPermission = BasePermission & {
|
|
|
49
73
|
justification?: string;
|
|
50
74
|
};
|
|
51
75
|
};
|
|
76
|
+
type NativeTokenAllowancePermission = BasePermission & {
|
|
77
|
+
type: 'native-token-allowance';
|
|
78
|
+
data: {
|
|
79
|
+
allowanceAmount: bigint;
|
|
80
|
+
startTime?: number;
|
|
81
|
+
justification?: string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
type Erc20TokenAllowancePermission = BasePermission & {
|
|
85
|
+
type: 'erc20-token-allowance';
|
|
86
|
+
data: {
|
|
87
|
+
allowanceAmount: bigint;
|
|
88
|
+
startTime?: number;
|
|
89
|
+
tokenAddress: Address;
|
|
90
|
+
justification?: string;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
52
93
|
type Erc20TokenRevocationPermission = BasePermission & {
|
|
53
94
|
type: 'erc20-token-revocation';
|
|
54
95
|
data: {
|
|
55
96
|
justification?: string;
|
|
56
97
|
};
|
|
57
98
|
};
|
|
58
|
-
type PermissionTypes = NativeTokenStreamPermission | NativeTokenPeriodicPermission | Erc20TokenStreamPermission | Erc20TokenPeriodicPermission | Erc20TokenRevocationPermission;
|
|
99
|
+
type PermissionTypes = NativeTokenStreamPermission | NativeTokenPeriodicPermission | NativeTokenAllowancePermission | Erc20TokenStreamPermission | Erc20TokenPeriodicPermission | Erc20TokenAllowancePermission | Erc20TokenRevocationPermission;
|
|
59
100
|
type PermissionRequestParameter = {
|
|
60
101
|
chainId: number;
|
|
61
102
|
permission: PermissionTypes;
|
|
@@ -63,6 +104,7 @@ type PermissionRequestParameter = {
|
|
|
63
104
|
from?: Address | undefined | null;
|
|
64
105
|
expiry?: number | undefined | null;
|
|
65
106
|
redeemer?: readonly Address[] | undefined | null;
|
|
107
|
+
payee?: readonly Address[] | undefined | null;
|
|
66
108
|
};
|
|
67
109
|
type SupportedPermissionInfo = {
|
|
68
110
|
chainIds: number[];
|
|
@@ -218,8 +260,11 @@ declare const erc7715ProviderActions: () => (client: Client) => {
|
|
|
218
260
|
getGrantedExecutionPermissions: () => Promise<GetGrantedExecutionPermissionsResult>;
|
|
219
261
|
};
|
|
220
262
|
type Erc7715Client = Client & ReturnType<ReturnType<typeof erc7715ProviderActions>>;
|
|
263
|
+
type Erc7710WalletClient = WalletClient & ReturnType<ReturnType<typeof erc7710WalletActions>>;
|
|
221
264
|
declare const erc7710WalletActions: () => (client: WalletClient) => {
|
|
222
265
|
sendTransactionWithDelegation: (args: SendTransactionWithDelegationParameters) => Promise<`0x${string}`>;
|
|
266
|
+
redelegatePermissionContext: (parameters: RedelegatePermissionContextParameters) => Promise<RedelegatePermissionContextReturnType>;
|
|
267
|
+
redelegatePermissionContextOpen: (parameters: RedelegatePermissionContextOpenParameters) => Promise<RedelegatePermissionContextReturnType>;
|
|
223
268
|
};
|
|
224
269
|
declare const erc7710BundlerActions: () => (client: Client) => {
|
|
225
270
|
sendUserOperationWithDelegation: (args: SendUserOperationWithDelegationParameters) => Promise<`0x${string}`>;
|
|
@@ -227,19 +272,25 @@ declare const erc7710BundlerActions: () => (client: Client) => {
|
|
|
227
272
|
|
|
228
273
|
type index_CaveatEnforcerParams = CaveatEnforcerParams;
|
|
229
274
|
type index_DelegatedCall = DelegatedCall;
|
|
275
|
+
type index_Erc20TokenAllowancePermission = Erc20TokenAllowancePermission;
|
|
230
276
|
type index_Erc20TokenPeriodicPermission = Erc20TokenPeriodicPermission;
|
|
231
277
|
type index_Erc20TokenRevocationPermission = Erc20TokenRevocationPermission;
|
|
232
278
|
type index_Erc20TokenStreamPermission = Erc20TokenStreamPermission;
|
|
279
|
+
type index_Erc7710WalletClient = Erc7710WalletClient;
|
|
233
280
|
type index_Erc7715Client = Erc7715Client;
|
|
234
281
|
type index_GetGrantedExecutionPermissionsResult = GetGrantedExecutionPermissionsResult;
|
|
235
282
|
type index_GetSupportedExecutionPermissionsResult = GetSupportedExecutionPermissionsResult;
|
|
236
283
|
type index_MetaMaskExtensionClient = MetaMaskExtensionClient;
|
|
237
284
|
type index_MetaMaskExtensionSchema = MetaMaskExtensionSchema;
|
|
285
|
+
type index_NativeTokenAllowancePermission = NativeTokenAllowancePermission;
|
|
238
286
|
type index_NativeTokenPeriodicPermission = NativeTokenPeriodicPermission;
|
|
239
287
|
type index_NativeTokenStreamPermission = NativeTokenStreamPermission;
|
|
240
288
|
type index_PeriodTransferResult = PeriodTransferResult;
|
|
241
289
|
type index_PermissionRequestParameter = PermissionRequestParameter;
|
|
242
290
|
type index_PermissionTypes = PermissionTypes;
|
|
291
|
+
type index_RedelegatePermissionContextOpenParameters = RedelegatePermissionContextOpenParameters;
|
|
292
|
+
type index_RedelegatePermissionContextParameters = RedelegatePermissionContextParameters;
|
|
293
|
+
type index_RedelegatePermissionContextReturnType = RedelegatePermissionContextReturnType;
|
|
243
294
|
type index_RequestExecutionPermissionsParameters = RequestExecutionPermissionsParameters;
|
|
244
295
|
type index_RequestExecutionPermissionsReturnType = RequestExecutionPermissionsReturnType;
|
|
245
296
|
type index_RpcGetGrantedExecutionPermissionsResult = RpcGetGrantedExecutionPermissionsResult;
|
|
@@ -262,12 +313,14 @@ declare const index_getMultiTokenPeriodEnforcerAvailableAmount: typeof getMultiT
|
|
|
262
313
|
declare const index_getNativeTokenPeriodTransferEnforcerAvailableAmount: typeof getNativeTokenPeriodTransferEnforcerAvailableAmount;
|
|
263
314
|
declare const index_getNativeTokenStreamingEnforcerAvailableAmount: typeof getNativeTokenStreamingEnforcerAvailableAmount;
|
|
264
315
|
declare const index_isValid7702Implementation: typeof isValid7702Implementation;
|
|
316
|
+
declare const index_redelegatePermissionContextAction: typeof redelegatePermissionContextAction;
|
|
317
|
+
declare const index_redelegatePermissionContextOpenAction: typeof redelegatePermissionContextOpenAction;
|
|
265
318
|
declare const index_signDelegation: typeof signDelegation;
|
|
266
319
|
declare const index_signDelegationActions: typeof signDelegationActions;
|
|
267
320
|
declare const index_signUserOperation: typeof signUserOperation;
|
|
268
321
|
declare const index_signUserOperationActions: typeof signUserOperationActions;
|
|
269
322
|
declare namespace index {
|
|
270
|
-
export { type index_CaveatEnforcerParams as CaveatEnforcerParams, type index_DelegatedCall as DelegatedCall, type index_Erc20TokenPeriodicPermission as Erc20TokenPeriodicPermission, type index_Erc20TokenRevocationPermission as Erc20TokenRevocationPermission, type index_Erc20TokenStreamPermission as Erc20TokenStreamPermission, type index_Erc7715Client as Erc7715Client, type index_GetGrantedExecutionPermissionsResult as GetGrantedExecutionPermissionsResult, type index_GetSupportedExecutionPermissionsResult as GetSupportedExecutionPermissionsResult, type index_MetaMaskExtensionClient as MetaMaskExtensionClient, type index_MetaMaskExtensionSchema as MetaMaskExtensionSchema, type index_NativeTokenPeriodicPermission as NativeTokenPeriodicPermission, type index_NativeTokenStreamPermission as NativeTokenStreamPermission, type index_PeriodTransferResult as PeriodTransferResult, type index_PermissionRequestParameter as PermissionRequestParameter, type index_PermissionTypes as PermissionTypes, type index_RequestExecutionPermissionsParameters as RequestExecutionPermissionsParameters, type index_RequestExecutionPermissionsReturnType as RequestExecutionPermissionsReturnType, type index_RpcGetGrantedExecutionPermissionsResult as RpcGetGrantedExecutionPermissionsResult, type index_RpcGetSupportedExecutionPermissionsResult as RpcGetSupportedExecutionPermissionsResult, type index_RpcSupportedPermissionInfo as RpcSupportedPermissionInfo, index_Rule as Rule, type index_SignDelegationParameters as SignDelegationParameters, type index_SignDelegationReturnType as SignDelegationReturnType, type index_SignUserOperationParameters as SignUserOperationParameters, type index_SignUserOperationReturnType as SignUserOperationReturnType, type index_StreamingResult as StreamingResult, type index_SupportedPermissionInfo as SupportedPermissionInfo, index_caveatEnforcerActions as caveatEnforcerActions, index_erc7710BundlerActions as erc7710BundlerActions, index_erc7710WalletActions as erc7710WalletActions, index_erc7715ProviderActions as erc7715ProviderActions, index_getErc20PeriodTransferEnforcerAvailableAmount as getErc20PeriodTransferEnforcerAvailableAmount, index_getErc20StreamingEnforcerAvailableAmount as getErc20StreamingEnforcerAvailableAmount, erc7715GetGrantedExecutionPermissionsAction as getGrantedExecutionPermissions, index_getMultiTokenPeriodEnforcerAvailableAmount as getMultiTokenPeriodEnforcerAvailableAmount, index_getNativeTokenPeriodTransferEnforcerAvailableAmount as getNativeTokenPeriodTransferEnforcerAvailableAmount, index_getNativeTokenStreamingEnforcerAvailableAmount as getNativeTokenStreamingEnforcerAvailableAmount, erc7715GetSupportedExecutionPermissionsAction as getSupportedExecutionPermissions, index_isValid7702Implementation as isValid7702Implementation, erc7715RequestExecutionPermissionsAction as requestExecutionPermissions, index_signDelegation as signDelegation, index_signDelegationActions as signDelegationActions, index_signUserOperation as signUserOperation, index_signUserOperationActions as signUserOperationActions };
|
|
323
|
+
export { type index_CaveatEnforcerParams as CaveatEnforcerParams, type index_DelegatedCall as DelegatedCall, type index_Erc20TokenAllowancePermission as Erc20TokenAllowancePermission, type index_Erc20TokenPeriodicPermission as Erc20TokenPeriodicPermission, type index_Erc20TokenRevocationPermission as Erc20TokenRevocationPermission, type index_Erc20TokenStreamPermission as Erc20TokenStreamPermission, type index_Erc7710WalletClient as Erc7710WalletClient, type index_Erc7715Client as Erc7715Client, type index_GetGrantedExecutionPermissionsResult as GetGrantedExecutionPermissionsResult, type index_GetSupportedExecutionPermissionsResult as GetSupportedExecutionPermissionsResult, type index_MetaMaskExtensionClient as MetaMaskExtensionClient, type index_MetaMaskExtensionSchema as MetaMaskExtensionSchema, type index_NativeTokenAllowancePermission as NativeTokenAllowancePermission, type index_NativeTokenPeriodicPermission as NativeTokenPeriodicPermission, type index_NativeTokenStreamPermission as NativeTokenStreamPermission, type index_PeriodTransferResult as PeriodTransferResult, type index_PermissionRequestParameter as PermissionRequestParameter, type index_PermissionTypes as PermissionTypes, type index_RedelegatePermissionContextOpenParameters as RedelegatePermissionContextOpenParameters, type index_RedelegatePermissionContextParameters as RedelegatePermissionContextParameters, type index_RedelegatePermissionContextReturnType as RedelegatePermissionContextReturnType, type index_RequestExecutionPermissionsParameters as RequestExecutionPermissionsParameters, type index_RequestExecutionPermissionsReturnType as RequestExecutionPermissionsReturnType, type index_RpcGetGrantedExecutionPermissionsResult as RpcGetGrantedExecutionPermissionsResult, type index_RpcGetSupportedExecutionPermissionsResult as RpcGetSupportedExecutionPermissionsResult, type index_RpcSupportedPermissionInfo as RpcSupportedPermissionInfo, index_Rule as Rule, type index_SignDelegationParameters as SignDelegationParameters, type index_SignDelegationReturnType as SignDelegationReturnType, type index_SignUserOperationParameters as SignUserOperationParameters, type index_SignUserOperationReturnType as SignUserOperationReturnType, type index_StreamingResult as StreamingResult, type index_SupportedPermissionInfo as SupportedPermissionInfo, index_caveatEnforcerActions as caveatEnforcerActions, index_erc7710BundlerActions as erc7710BundlerActions, index_erc7710WalletActions as erc7710WalletActions, index_erc7715ProviderActions as erc7715ProviderActions, index_getErc20PeriodTransferEnforcerAvailableAmount as getErc20PeriodTransferEnforcerAvailableAmount, index_getErc20StreamingEnforcerAvailableAmount as getErc20StreamingEnforcerAvailableAmount, erc7715GetGrantedExecutionPermissionsAction as getGrantedExecutionPermissions, index_getMultiTokenPeriodEnforcerAvailableAmount as getMultiTokenPeriodEnforcerAvailableAmount, index_getNativeTokenPeriodTransferEnforcerAvailableAmount as getNativeTokenPeriodTransferEnforcerAvailableAmount, index_getNativeTokenStreamingEnforcerAvailableAmount as getNativeTokenStreamingEnforcerAvailableAmount, erc7715GetSupportedExecutionPermissionsAction as getSupportedExecutionPermissions, index_isValid7702Implementation as isValid7702Implementation, index_redelegatePermissionContextAction as redelegatePermissionContextAction, index_redelegatePermissionContextOpenAction as redelegatePermissionContextOpenAction, erc7715RequestExecutionPermissionsAction as requestExecutionPermissions, index_signDelegation as signDelegation, index_signDelegationActions as signDelegationActions, index_signUserOperation as signUserOperation, index_signUserOperationActions as signUserOperationActions };
|
|
271
324
|
}
|
|
272
325
|
|
|
273
|
-
export {
|
|
326
|
+
export { erc7710WalletActions as A, erc7715ProviderActions as B, type CaveatEnforcerParams as C, type DelegatedCall as D, type Erc20TokenAllowancePermission as E, getErc20PeriodTransferEnforcerAvailableAmount as F, type GetGrantedExecutionPermissionsResult as G, getErc20StreamingEnforcerAvailableAmount as H, erc7715GetGrantedExecutionPermissionsAction as I, getMultiTokenPeriodEnforcerAvailableAmount as J, getNativeTokenPeriodTransferEnforcerAvailableAmount as K, getNativeTokenStreamingEnforcerAvailableAmount as L, type MetaMaskExtensionClient as M, type NativeTokenAllowancePermission as N, erc7715GetSupportedExecutionPermissionsAction as O, type PeriodTransferResult as P, isValid7702Implementation as Q, type RedelegatePermissionContextOpenParameters as R, type SignDelegationParameters as S, redelegatePermissionContextAction as T, redelegatePermissionContextOpenAction as U, erc7715RequestExecutionPermissionsAction as V, signDelegation as W, signDelegationActions as X, signUserOperation as Y, signUserOperationActions as Z, type Erc20TokenPeriodicPermission as a, type Erc20TokenRevocationPermission as b, caveatEnforcerActions as c, type Erc20TokenStreamPermission as d, type Erc7710WalletClient as e, type Erc7715Client as f, type GetSupportedExecutionPermissionsResult as g, type MetaMaskExtensionSchema as h, index as i, type NativeTokenPeriodicPermission as j, type NativeTokenStreamPermission as k, type PermissionRequestParameter as l, type PermissionTypes as m, type RedelegatePermissionContextParameters as n, type RedelegatePermissionContextReturnType as o, type RequestExecutionPermissionsParameters as p, type RequestExecutionPermissionsReturnType as q, type RpcGetGrantedExecutionPermissionsResult as r, type RpcGetSupportedExecutionPermissionsResult as s, type RpcSupportedPermissionInfo as t, type SignDelegationReturnType as u, type SignUserOperationParameters as v, type SignUserOperationReturnType as w, type StreamingResult as x, type SupportedPermissionInfo as y, erc7710BundlerActions as z };
|
|
@@ -1,9 +1,33 @@
|
|
|
1
|
+
import { Account, Address, Hex, Chain, Client, Transport, WalletClient, RpcSchema, OneOf, SendTransactionRequest, SendTransactionParameters, PublicClient } from 'viem';
|
|
2
|
+
import { S as SmartAccountsEnvironment, P as PermissionContext, D as Delegation, l as Call } from './types-BWaH4KH1.js';
|
|
3
|
+
import { S as ScopeConfig, C as Caveats } from './resolveCaveats-s2snaFEo.js';
|
|
1
4
|
import { Rule, PermissionRequest as PermissionRequest$1, PermissionTypes as PermissionTypes$1, PermissionResponse as PermissionResponse$1 } from '@metamask/7715-permission-types';
|
|
2
|
-
import { Address, Hex, Client, Transport, Chain, Account, RpcSchema, OneOf, PublicClient, SendTransactionRequest, SendTransactionParameters, WalletClient } from 'viem';
|
|
3
5
|
import { SmartAccount, SendUserOperationParameters } from 'viem/account-abstraction';
|
|
4
|
-
import { l as Call, P as PermissionContext, S as SmartAccountsEnvironment, D as Delegation } from './types-BWaH4KH1.js';
|
|
5
6
|
import { U as UserOperationV07 } from './userOp-DKgjzz7B.js';
|
|
6
7
|
|
|
8
|
+
type BaseRedelegatePermissionContextParameters = {
|
|
9
|
+
account?: Account | Address;
|
|
10
|
+
environment: SmartAccountsEnvironment;
|
|
11
|
+
permissionContext: PermissionContext;
|
|
12
|
+
chainId?: number;
|
|
13
|
+
scope?: ScopeConfig;
|
|
14
|
+
caveats?: Caveats;
|
|
15
|
+
salt?: Hex;
|
|
16
|
+
};
|
|
17
|
+
type RedelegatePermissionContextParameters = BaseRedelegatePermissionContextParameters & {
|
|
18
|
+
to: Address;
|
|
19
|
+
};
|
|
20
|
+
type RedelegatePermissionContextOpenParameters = BaseRedelegatePermissionContextParameters;
|
|
21
|
+
type RedelegatePermissionContextReturnType = {
|
|
22
|
+
delegation: Delegation;
|
|
23
|
+
permissionContext: Hex;
|
|
24
|
+
};
|
|
25
|
+
type SigningClient<TChain extends Chain | undefined, TAccount extends Account | undefined> = Client<Transport, TChain, TAccount> & {
|
|
26
|
+
signTypedData: WalletClient['signTypedData'];
|
|
27
|
+
};
|
|
28
|
+
declare function redelegatePermissionContextAction<TChain extends Chain | undefined, TAccount extends Account | undefined>(client: SigningClient<TChain, TAccount>, parameters: RedelegatePermissionContextParameters): Promise<RedelegatePermissionContextReturnType>;
|
|
29
|
+
declare function redelegatePermissionContextOpenAction<TChain extends Chain | undefined, TAccount extends Account | undefined>(client: SigningClient<TChain, TAccount>, parameters: RedelegatePermissionContextOpenParameters): Promise<RedelegatePermissionContextReturnType>;
|
|
30
|
+
|
|
7
31
|
type BasePermission = {
|
|
8
32
|
type: string;
|
|
9
33
|
isAdjustmentAllowed: boolean;
|
|
@@ -49,13 +73,30 @@ type Erc20TokenPeriodicPermission = BasePermission & {
|
|
|
49
73
|
justification?: string;
|
|
50
74
|
};
|
|
51
75
|
};
|
|
76
|
+
type NativeTokenAllowancePermission = BasePermission & {
|
|
77
|
+
type: 'native-token-allowance';
|
|
78
|
+
data: {
|
|
79
|
+
allowanceAmount: bigint;
|
|
80
|
+
startTime?: number;
|
|
81
|
+
justification?: string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
type Erc20TokenAllowancePermission = BasePermission & {
|
|
85
|
+
type: 'erc20-token-allowance';
|
|
86
|
+
data: {
|
|
87
|
+
allowanceAmount: bigint;
|
|
88
|
+
startTime?: number;
|
|
89
|
+
tokenAddress: Address;
|
|
90
|
+
justification?: string;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
52
93
|
type Erc20TokenRevocationPermission = BasePermission & {
|
|
53
94
|
type: 'erc20-token-revocation';
|
|
54
95
|
data: {
|
|
55
96
|
justification?: string;
|
|
56
97
|
};
|
|
57
98
|
};
|
|
58
|
-
type PermissionTypes = NativeTokenStreamPermission | NativeTokenPeriodicPermission | Erc20TokenStreamPermission | Erc20TokenPeriodicPermission | Erc20TokenRevocationPermission;
|
|
99
|
+
type PermissionTypes = NativeTokenStreamPermission | NativeTokenPeriodicPermission | NativeTokenAllowancePermission | Erc20TokenStreamPermission | Erc20TokenPeriodicPermission | Erc20TokenAllowancePermission | Erc20TokenRevocationPermission;
|
|
59
100
|
type PermissionRequestParameter = {
|
|
60
101
|
chainId: number;
|
|
61
102
|
permission: PermissionTypes;
|
|
@@ -63,6 +104,7 @@ type PermissionRequestParameter = {
|
|
|
63
104
|
from?: Address | undefined | null;
|
|
64
105
|
expiry?: number | undefined | null;
|
|
65
106
|
redeemer?: readonly Address[] | undefined | null;
|
|
107
|
+
payee?: readonly Address[] | undefined | null;
|
|
66
108
|
};
|
|
67
109
|
type SupportedPermissionInfo = {
|
|
68
110
|
chainIds: number[];
|
|
@@ -218,8 +260,11 @@ declare const erc7715ProviderActions: () => (client: Client) => {
|
|
|
218
260
|
getGrantedExecutionPermissions: () => Promise<GetGrantedExecutionPermissionsResult>;
|
|
219
261
|
};
|
|
220
262
|
type Erc7715Client = Client & ReturnType<ReturnType<typeof erc7715ProviderActions>>;
|
|
263
|
+
type Erc7710WalletClient = WalletClient & ReturnType<ReturnType<typeof erc7710WalletActions>>;
|
|
221
264
|
declare const erc7710WalletActions: () => (client: WalletClient) => {
|
|
222
265
|
sendTransactionWithDelegation: (args: SendTransactionWithDelegationParameters) => Promise<`0x${string}`>;
|
|
266
|
+
redelegatePermissionContext: (parameters: RedelegatePermissionContextParameters) => Promise<RedelegatePermissionContextReturnType>;
|
|
267
|
+
redelegatePermissionContextOpen: (parameters: RedelegatePermissionContextOpenParameters) => Promise<RedelegatePermissionContextReturnType>;
|
|
223
268
|
};
|
|
224
269
|
declare const erc7710BundlerActions: () => (client: Client) => {
|
|
225
270
|
sendUserOperationWithDelegation: (args: SendUserOperationWithDelegationParameters) => Promise<`0x${string}`>;
|
|
@@ -227,19 +272,25 @@ declare const erc7710BundlerActions: () => (client: Client) => {
|
|
|
227
272
|
|
|
228
273
|
type index_CaveatEnforcerParams = CaveatEnforcerParams;
|
|
229
274
|
type index_DelegatedCall = DelegatedCall;
|
|
275
|
+
type index_Erc20TokenAllowancePermission = Erc20TokenAllowancePermission;
|
|
230
276
|
type index_Erc20TokenPeriodicPermission = Erc20TokenPeriodicPermission;
|
|
231
277
|
type index_Erc20TokenRevocationPermission = Erc20TokenRevocationPermission;
|
|
232
278
|
type index_Erc20TokenStreamPermission = Erc20TokenStreamPermission;
|
|
279
|
+
type index_Erc7710WalletClient = Erc7710WalletClient;
|
|
233
280
|
type index_Erc7715Client = Erc7715Client;
|
|
234
281
|
type index_GetGrantedExecutionPermissionsResult = GetGrantedExecutionPermissionsResult;
|
|
235
282
|
type index_GetSupportedExecutionPermissionsResult = GetSupportedExecutionPermissionsResult;
|
|
236
283
|
type index_MetaMaskExtensionClient = MetaMaskExtensionClient;
|
|
237
284
|
type index_MetaMaskExtensionSchema = MetaMaskExtensionSchema;
|
|
285
|
+
type index_NativeTokenAllowancePermission = NativeTokenAllowancePermission;
|
|
238
286
|
type index_NativeTokenPeriodicPermission = NativeTokenPeriodicPermission;
|
|
239
287
|
type index_NativeTokenStreamPermission = NativeTokenStreamPermission;
|
|
240
288
|
type index_PeriodTransferResult = PeriodTransferResult;
|
|
241
289
|
type index_PermissionRequestParameter = PermissionRequestParameter;
|
|
242
290
|
type index_PermissionTypes = PermissionTypes;
|
|
291
|
+
type index_RedelegatePermissionContextOpenParameters = RedelegatePermissionContextOpenParameters;
|
|
292
|
+
type index_RedelegatePermissionContextParameters = RedelegatePermissionContextParameters;
|
|
293
|
+
type index_RedelegatePermissionContextReturnType = RedelegatePermissionContextReturnType;
|
|
243
294
|
type index_RequestExecutionPermissionsParameters = RequestExecutionPermissionsParameters;
|
|
244
295
|
type index_RequestExecutionPermissionsReturnType = RequestExecutionPermissionsReturnType;
|
|
245
296
|
type index_RpcGetGrantedExecutionPermissionsResult = RpcGetGrantedExecutionPermissionsResult;
|
|
@@ -262,12 +313,14 @@ declare const index_getMultiTokenPeriodEnforcerAvailableAmount: typeof getMultiT
|
|
|
262
313
|
declare const index_getNativeTokenPeriodTransferEnforcerAvailableAmount: typeof getNativeTokenPeriodTransferEnforcerAvailableAmount;
|
|
263
314
|
declare const index_getNativeTokenStreamingEnforcerAvailableAmount: typeof getNativeTokenStreamingEnforcerAvailableAmount;
|
|
264
315
|
declare const index_isValid7702Implementation: typeof isValid7702Implementation;
|
|
316
|
+
declare const index_redelegatePermissionContextAction: typeof redelegatePermissionContextAction;
|
|
317
|
+
declare const index_redelegatePermissionContextOpenAction: typeof redelegatePermissionContextOpenAction;
|
|
265
318
|
declare const index_signDelegation: typeof signDelegation;
|
|
266
319
|
declare const index_signDelegationActions: typeof signDelegationActions;
|
|
267
320
|
declare const index_signUserOperation: typeof signUserOperation;
|
|
268
321
|
declare const index_signUserOperationActions: typeof signUserOperationActions;
|
|
269
322
|
declare namespace index {
|
|
270
|
-
export { type index_CaveatEnforcerParams as CaveatEnforcerParams, type index_DelegatedCall as DelegatedCall, type index_Erc20TokenPeriodicPermission as Erc20TokenPeriodicPermission, type index_Erc20TokenRevocationPermission as Erc20TokenRevocationPermission, type index_Erc20TokenStreamPermission as Erc20TokenStreamPermission, type index_Erc7715Client as Erc7715Client, type index_GetGrantedExecutionPermissionsResult as GetGrantedExecutionPermissionsResult, type index_GetSupportedExecutionPermissionsResult as GetSupportedExecutionPermissionsResult, type index_MetaMaskExtensionClient as MetaMaskExtensionClient, type index_MetaMaskExtensionSchema as MetaMaskExtensionSchema, type index_NativeTokenPeriodicPermission as NativeTokenPeriodicPermission, type index_NativeTokenStreamPermission as NativeTokenStreamPermission, type index_PeriodTransferResult as PeriodTransferResult, type index_PermissionRequestParameter as PermissionRequestParameter, type index_PermissionTypes as PermissionTypes, type index_RequestExecutionPermissionsParameters as RequestExecutionPermissionsParameters, type index_RequestExecutionPermissionsReturnType as RequestExecutionPermissionsReturnType, type index_RpcGetGrantedExecutionPermissionsResult as RpcGetGrantedExecutionPermissionsResult, type index_RpcGetSupportedExecutionPermissionsResult as RpcGetSupportedExecutionPermissionsResult, type index_RpcSupportedPermissionInfo as RpcSupportedPermissionInfo, index_Rule as Rule, type index_SignDelegationParameters as SignDelegationParameters, type index_SignDelegationReturnType as SignDelegationReturnType, type index_SignUserOperationParameters as SignUserOperationParameters, type index_SignUserOperationReturnType as SignUserOperationReturnType, type index_StreamingResult as StreamingResult, type index_SupportedPermissionInfo as SupportedPermissionInfo, index_caveatEnforcerActions as caveatEnforcerActions, index_erc7710BundlerActions as erc7710BundlerActions, index_erc7710WalletActions as erc7710WalletActions, index_erc7715ProviderActions as erc7715ProviderActions, index_getErc20PeriodTransferEnforcerAvailableAmount as getErc20PeriodTransferEnforcerAvailableAmount, index_getErc20StreamingEnforcerAvailableAmount as getErc20StreamingEnforcerAvailableAmount, erc7715GetGrantedExecutionPermissionsAction as getGrantedExecutionPermissions, index_getMultiTokenPeriodEnforcerAvailableAmount as getMultiTokenPeriodEnforcerAvailableAmount, index_getNativeTokenPeriodTransferEnforcerAvailableAmount as getNativeTokenPeriodTransferEnforcerAvailableAmount, index_getNativeTokenStreamingEnforcerAvailableAmount as getNativeTokenStreamingEnforcerAvailableAmount, erc7715GetSupportedExecutionPermissionsAction as getSupportedExecutionPermissions, index_isValid7702Implementation as isValid7702Implementation, erc7715RequestExecutionPermissionsAction as requestExecutionPermissions, index_signDelegation as signDelegation, index_signDelegationActions as signDelegationActions, index_signUserOperation as signUserOperation, index_signUserOperationActions as signUserOperationActions };
|
|
323
|
+
export { type index_CaveatEnforcerParams as CaveatEnforcerParams, type index_DelegatedCall as DelegatedCall, type index_Erc20TokenAllowancePermission as Erc20TokenAllowancePermission, type index_Erc20TokenPeriodicPermission as Erc20TokenPeriodicPermission, type index_Erc20TokenRevocationPermission as Erc20TokenRevocationPermission, type index_Erc20TokenStreamPermission as Erc20TokenStreamPermission, type index_Erc7710WalletClient as Erc7710WalletClient, type index_Erc7715Client as Erc7715Client, type index_GetGrantedExecutionPermissionsResult as GetGrantedExecutionPermissionsResult, type index_GetSupportedExecutionPermissionsResult as GetSupportedExecutionPermissionsResult, type index_MetaMaskExtensionClient as MetaMaskExtensionClient, type index_MetaMaskExtensionSchema as MetaMaskExtensionSchema, type index_NativeTokenAllowancePermission as NativeTokenAllowancePermission, type index_NativeTokenPeriodicPermission as NativeTokenPeriodicPermission, type index_NativeTokenStreamPermission as NativeTokenStreamPermission, type index_PeriodTransferResult as PeriodTransferResult, type index_PermissionRequestParameter as PermissionRequestParameter, type index_PermissionTypes as PermissionTypes, type index_RedelegatePermissionContextOpenParameters as RedelegatePermissionContextOpenParameters, type index_RedelegatePermissionContextParameters as RedelegatePermissionContextParameters, type index_RedelegatePermissionContextReturnType as RedelegatePermissionContextReturnType, type index_RequestExecutionPermissionsParameters as RequestExecutionPermissionsParameters, type index_RequestExecutionPermissionsReturnType as RequestExecutionPermissionsReturnType, type index_RpcGetGrantedExecutionPermissionsResult as RpcGetGrantedExecutionPermissionsResult, type index_RpcGetSupportedExecutionPermissionsResult as RpcGetSupportedExecutionPermissionsResult, type index_RpcSupportedPermissionInfo as RpcSupportedPermissionInfo, index_Rule as Rule, type index_SignDelegationParameters as SignDelegationParameters, type index_SignDelegationReturnType as SignDelegationReturnType, type index_SignUserOperationParameters as SignUserOperationParameters, type index_SignUserOperationReturnType as SignUserOperationReturnType, type index_StreamingResult as StreamingResult, type index_SupportedPermissionInfo as SupportedPermissionInfo, index_caveatEnforcerActions as caveatEnforcerActions, index_erc7710BundlerActions as erc7710BundlerActions, index_erc7710WalletActions as erc7710WalletActions, index_erc7715ProviderActions as erc7715ProviderActions, index_getErc20PeriodTransferEnforcerAvailableAmount as getErc20PeriodTransferEnforcerAvailableAmount, index_getErc20StreamingEnforcerAvailableAmount as getErc20StreamingEnforcerAvailableAmount, erc7715GetGrantedExecutionPermissionsAction as getGrantedExecutionPermissions, index_getMultiTokenPeriodEnforcerAvailableAmount as getMultiTokenPeriodEnforcerAvailableAmount, index_getNativeTokenPeriodTransferEnforcerAvailableAmount as getNativeTokenPeriodTransferEnforcerAvailableAmount, index_getNativeTokenStreamingEnforcerAvailableAmount as getNativeTokenStreamingEnforcerAvailableAmount, erc7715GetSupportedExecutionPermissionsAction as getSupportedExecutionPermissions, index_isValid7702Implementation as isValid7702Implementation, index_redelegatePermissionContextAction as redelegatePermissionContextAction, index_redelegatePermissionContextOpenAction as redelegatePermissionContextOpenAction, erc7715RequestExecutionPermissionsAction as requestExecutionPermissions, index_signDelegation as signDelegation, index_signDelegationActions as signDelegationActions, index_signUserOperation as signUserOperation, index_signUserOperationActions as signUserOperationActions };
|
|
271
324
|
}
|
|
272
325
|
|
|
273
|
-
export {
|
|
326
|
+
export { erc7710WalletActions as A, erc7715ProviderActions as B, type CaveatEnforcerParams as C, type DelegatedCall as D, type Erc20TokenAllowancePermission as E, getErc20PeriodTransferEnforcerAvailableAmount as F, type GetGrantedExecutionPermissionsResult as G, getErc20StreamingEnforcerAvailableAmount as H, erc7715GetGrantedExecutionPermissionsAction as I, getMultiTokenPeriodEnforcerAvailableAmount as J, getNativeTokenPeriodTransferEnforcerAvailableAmount as K, getNativeTokenStreamingEnforcerAvailableAmount as L, type MetaMaskExtensionClient as M, type NativeTokenAllowancePermission as N, erc7715GetSupportedExecutionPermissionsAction as O, type PeriodTransferResult as P, isValid7702Implementation as Q, type RedelegatePermissionContextOpenParameters as R, type SignDelegationParameters as S, redelegatePermissionContextAction as T, redelegatePermissionContextOpenAction as U, erc7715RequestExecutionPermissionsAction as V, signDelegation as W, signDelegationActions as X, signUserOperation as Y, signUserOperationActions as Z, type Erc20TokenPeriodicPermission as a, type Erc20TokenRevocationPermission as b, caveatEnforcerActions as c, type Erc20TokenStreamPermission as d, type Erc7710WalletClient as e, type Erc7715Client as f, type GetSupportedExecutionPermissionsResult as g, type MetaMaskExtensionSchema as h, index as i, type NativeTokenPeriodicPermission as j, type NativeTokenStreamPermission as k, type PermissionRequestParameter as l, type PermissionTypes as m, type RedelegatePermissionContextParameters as n, type RedelegatePermissionContextReturnType as o, type RequestExecutionPermissionsParameters as p, type RequestExecutionPermissionsReturnType as q, type RpcGetGrantedExecutionPermissionsResult as r, type RpcGetSupportedExecutionPermissionsResult as s, type RpcSupportedPermissionInfo as t, type SignDelegationReturnType as u, type SignUserOperationParameters as v, type SignUserOperationReturnType as w, type StreamingResult as x, type SupportedPermissionInfo as y, erc7710BundlerActions as z };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ANY_BENEFICIARY, ROOT_AUTHORITY } from '@metamask/delegation-core';
|
|
2
2
|
import * as viem from 'viem';
|
|
3
3
|
import { Client, Transport, Chain, Account, Address, Hex } from 'viem';
|
|
4
|
-
import {
|
|
4
|
+
import { f as DelegationStruct } from './delegation-BKkEyxZY.cjs';
|
|
5
5
|
import { D as Delegation, P as PermissionContext } from './types-BWaH4KH1.cjs';
|
|
6
|
+
import { E as ExecutionMode, b as ExecutionStruct } from './resolveCaveats-DiqGB-T5.cjs';
|
|
6
7
|
|
|
7
8
|
declare const NAME$1 = "DelegationManager";
|
|
8
9
|
declare const VERSION$1 = "1.3.0";
|
package/dist/index.cjs
CHANGED
|
@@ -2,24 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkXEOE25DEcjs = require('./chunk-XEOE25DE.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
require('./chunk-
|
|
8
|
+
var _chunkDN4O5VOPcjs = require('./chunk-DN4O5VOP.cjs');
|
|
9
|
+
require('./chunk-7FYDQNJ3.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkSCS3CFREcjs = require('./chunk-SCS3CFRE.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
var _chunkSOFB2MXGcjs = require('./chunk-SOFB2MXG.cjs');
|
|
22
|
-
require('./chunk-
|
|
22
|
+
require('./chunk-FH6HZCHI.cjs');
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
@@ -38,8 +38,7 @@ var _chunkMOHCTPYQcjs = require('./chunk-MOHCTPYQ.cjs');
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
var _chunkSZOX7K2Vcjs = require('./chunk-SZOX7K2V.cjs');
|
|
41
|
+
var _chunkIBZSNB7Dcjs = require('./chunk-IBZSNB7D.cjs');
|
|
43
42
|
|
|
44
43
|
// src/toMetaMaskSmartAccount.ts
|
|
45
44
|
|
|
@@ -62,7 +61,7 @@ var signatureTypes = ["ECDSA"];
|
|
|
62
61
|
var aggregateSignature = ({
|
|
63
62
|
signatures
|
|
64
63
|
}) => {
|
|
65
|
-
|
|
64
|
+
_chunkIBZSNB7Dcjs.trackSmartAccountsKitFunctionCall.call(void 0, "aggregateSignature", {
|
|
66
65
|
signatureCount: signatures.length
|
|
67
66
|
});
|
|
68
67
|
if (signatures.length === 0) {
|
|
@@ -118,7 +117,7 @@ var resolveHybridSigner = (config) => {
|
|
|
118
117
|
if (webAuthnAccount.type !== "webAuthn") {
|
|
119
118
|
throw new Error("Account is not a webAuthn account");
|
|
120
119
|
}
|
|
121
|
-
const encodeSignature = (result) =>
|
|
120
|
+
const encodeSignature = (result) => _chunkSCS3CFREcjs.encodeDeleGatorSignature.call(void 0,
|
|
122
121
|
keyId,
|
|
123
122
|
result.signature,
|
|
124
123
|
result.webauthn.clientDataJSON,
|
|
@@ -126,7 +125,7 @@ var resolveHybridSigner = (config) => {
|
|
|
126
125
|
);
|
|
127
126
|
const signMessage = async (args) => webAuthnAccount.signMessage(args).then(encodeSignature);
|
|
128
127
|
const signTypedData = async (typedDataDefinition) => webAuthnAccount.signTypedData(typedDataDefinition).then(encodeSignature);
|
|
129
|
-
const getStubSignature = async () =>
|
|
128
|
+
const getStubSignature = async () => _chunkSCS3CFREcjs.createDummyWebAuthnSignature.call(void 0, keyId);
|
|
130
129
|
return {
|
|
131
130
|
signMessage,
|
|
132
131
|
signTypedData,
|
|
@@ -237,7 +236,7 @@ async function toMetaMaskSmartAccount(params) {
|
|
|
237
236
|
implementation,
|
|
238
237
|
nonceKeyManager
|
|
239
238
|
} = params;
|
|
240
|
-
|
|
239
|
+
_chunkIBZSNB7Dcjs.trackSmartAccountsKitFunctionCall.call(void 0, "toMetaMaskSmartAccount", {
|
|
241
240
|
implementation,
|
|
242
241
|
hasAddress: params.address !== void 0,
|
|
243
242
|
hasEnvironment: params.environment !== void 0,
|
|
@@ -259,7 +258,7 @@ async function toMetaMaskSmartAccount(params) {
|
|
|
259
258
|
if (implementation === "Stateless7702" /* Stateless7702 */) {
|
|
260
259
|
throw new Error("Stateless7702 does not support counterfactual accounts");
|
|
261
260
|
}
|
|
262
|
-
const accountData = await
|
|
261
|
+
const accountData = await _chunkSCS3CFREcjs.getCounterfactualAccountData.call(void 0, {
|
|
263
262
|
factory: environment.SimpleFactory,
|
|
264
263
|
implementations: environment.implementations,
|
|
265
264
|
implementation,
|
|
@@ -306,7 +305,7 @@ async function toMetaMaskSmartAccount(params) {
|
|
|
306
305
|
);
|
|
307
306
|
}
|
|
308
307
|
const { delegation, chainId } = delegationParams;
|
|
309
|
-
const delegationStruct =
|
|
308
|
+
const delegationStruct = _chunkIBZSNB7Dcjs.toDelegationStruct.call(void 0, {
|
|
310
309
|
...delegation,
|
|
311
310
|
signature: "0x"
|
|
312
311
|
});
|
|
@@ -317,7 +316,7 @@ async function toMetaMaskSmartAccount(params) {
|
|
|
317
316
|
version: "1",
|
|
318
317
|
verifyingContract: environment.DelegationManager
|
|
319
318
|
},
|
|
320
|
-
types:
|
|
319
|
+
types: _chunkIBZSNB7Dcjs.SIGNABLE_DELEGATION_TYPED_DATA,
|
|
321
320
|
primaryType: "Delegation",
|
|
322
321
|
message: delegationStruct
|
|
323
322
|
});
|
|
@@ -349,7 +348,7 @@ async function toMetaMaskSmartAccount(params) {
|
|
|
349
348
|
return signature;
|
|
350
349
|
};
|
|
351
350
|
const getAddress = async () => address;
|
|
352
|
-
const encodeCalls = async (calls) =>
|
|
351
|
+
const encodeCalls = async (calls) => _chunkSCS3CFREcjs.encodeCallsForCaller.call(void 0, address, calls);
|
|
353
352
|
const signerMethods = _nullishCoalesce(signer, () => ( {
|
|
354
353
|
signMessage: async () => {
|
|
355
354
|
throw new Error(
|
|
@@ -383,7 +382,7 @@ async function toMetaMaskSmartAccount(params) {
|
|
|
383
382
|
if (implementation === "Stateless7702" /* Stateless7702 */) {
|
|
384
383
|
return {
|
|
385
384
|
...smartAccount,
|
|
386
|
-
isDeployed: async () =>
|
|
385
|
+
isDeployed: async () => _chunkXEOE25DEcjs.isValid7702Implementation.call(void 0, {
|
|
387
386
|
client,
|
|
388
387
|
accountAddress: address,
|
|
389
388
|
environment
|
|
@@ -393,15 +392,18 @@ async function toMetaMaskSmartAccount(params) {
|
|
|
393
392
|
return smartAccount;
|
|
394
393
|
}
|
|
395
394
|
|
|
395
|
+
// src/index.ts
|
|
396
|
+
var _delegationcore = require('@metamask/delegation-core');
|
|
397
|
+
|
|
396
398
|
// src/actions/caveatEnforcerClient.ts
|
|
397
399
|
function createCaveatEnforcerClient({
|
|
398
400
|
client,
|
|
399
401
|
environment
|
|
400
402
|
}) {
|
|
401
|
-
|
|
403
|
+
_chunkIBZSNB7Dcjs.trackSmartAccountsKitFunctionCall.call(void 0, "createCaveatEnforcerClient", {
|
|
402
404
|
chainId: _nullishCoalesce(_optionalChain([client, 'access', _2 => _2.chain, 'optionalAccess', _3 => _3.id]), () => ( null))
|
|
403
405
|
});
|
|
404
|
-
return client.extend(
|
|
406
|
+
return client.extend(_chunkXEOE25DEcjs.caveatEnforcerActions.call(void 0, { environment }));
|
|
405
407
|
}
|
|
406
408
|
|
|
407
409
|
// src/actions/infuraBundlerClient.ts
|
|
@@ -429,7 +431,7 @@ var infuraBundlerActions = () => (client) => ({
|
|
|
429
431
|
}
|
|
430
432
|
});
|
|
431
433
|
function createInfuraBundlerClient(config) {
|
|
432
|
-
|
|
434
|
+
_chunkIBZSNB7Dcjs.trackSmartAccountsKitFunctionCall.call(void 0, "createInfuraBundlerClient", {
|
|
433
435
|
chainId: _nullishCoalesce(_optionalChain([config, 'access', _4 => _4.chain, 'optionalAccess', _5 => _5.id]), () => ( null))
|
|
434
436
|
});
|
|
435
437
|
const baseBundlerClient = _accountabstraction.createBundlerClient.call(void 0, config);
|
|
@@ -460,5 +462,5 @@ function createInfuraBundlerClient(config) {
|
|
|
460
462
|
|
|
461
463
|
|
|
462
464
|
|
|
463
|
-
exports.ANY_BENEFICIARY =
|
|
465
|
+
exports.ANY_BENEFICIARY = _chunkIBZSNB7Dcjs.ANY_BENEFICIARY; exports.BalanceChangeType = _delegationcore.BalanceChangeType; exports.CaveatType = _chunkIBZSNB7Dcjs.CaveatType; exports.ExecutionMode = _chunkMOHCTPYQcjs.ExecutionMode; exports.Implementation = _chunkIBZSNB7Dcjs.Implementation; exports.PREFERRED_VERSION = _chunkSOFB2MXGcjs.PREFERRED_VERSION; exports.ROOT_AUTHORITY = _chunkIBZSNB7Dcjs.ROOT_AUTHORITY; exports.ScopeType = _chunkIBZSNB7Dcjs.ScopeType; exports.TransferWindow = _chunkIBZSNB7Dcjs.TransferWindow; exports.actions = _chunkXEOE25DEcjs.actions_exports; exports.aggregateSignature = aggregateSignature; exports.contracts = _chunkDN4O5VOPcjs.contracts_exports; exports.createCaveat = _chunkIBZSNB7Dcjs.createCaveat; exports.createCaveatEnforcerClient = createCaveatEnforcerClient; exports.createDelegation = _chunkIBZSNB7Dcjs.createDelegation; exports.createExecution = _chunkMOHCTPYQcjs.createExecution; exports.createInfuraBundlerClient = createInfuraBundlerClient; exports.createOpenDelegation = _chunkIBZSNB7Dcjs.createOpenDelegation; exports.getSmartAccountsEnvironment = _chunkSOFB2MXGcjs.getSmartAccountsEnvironment; exports.signDelegation = _chunkIBZSNB7Dcjs.signDelegation; exports.signUserOperation = _chunkSOFB2MXGcjs.signUserOperation; exports.toMetaMaskSmartAccount = toMetaMaskSmartAccount;
|
|
464
466
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/index.cjs","../src/toMetaMaskSmartAccount.ts","../src/signer.ts","../src/signatures.ts","../src/actions/caveatEnforcerClient.ts","../src/actions/infuraBundlerClient.ts"],"names":["signTypedData","signMessage","getStubSignature","signUserOperation","signDelegation"],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;AC3CA;AACE;AACA;AACA;AAAA,2DACK;AAEP;AACE;AACA;AACA;AAAA,8DACK;AD4CP;AACA;AEvDA,4BAAuB;AFyDvB;AACA;AGzDA;AAIA,IAAM,eAAA,EAAiB,CAAC,OAAO,CAAA;AAoBxB,IAAM,mBAAA,EAAqB,CAAC;AAAA,EACjC;AACF,CAAA,EAAA,GAEW;AACT,EAAA,iEAAA,oBAAkC,EAAsB;AAAA,IACtD,cAAA,EAAgB,UAAA,CAAW;AAAA,EAC7B,CAAC,CAAA;AAED,EAAA,GAAA,CAAI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AAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACAG,IAAAA;AACAC,IAAAA;AACA,IAAA;AACG,IAAA;AACJ,EAAA;AAGG,EAAA;AACK,IAAA;AACF,MAAA;AAED,MAAA;AACE,QAAA;AACgB,QAAA;AAChB,QAAA;AACD,MAAA;AACL,IAAA;AACF,EAAA;AAGO,EAAA;AACT;ADoJsD;AACA;AI1WpD;AACA,EAAA;AACA,EAAA;AAIqD;AACnB,EAAA;AACH,IAAA;AAC9B,EAAA;AAE4C,EAAA;AAC/C;AJwWsD;AACA;AKrZtD;AACE;AAIK;AA2CiD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYmB,EAAA;AACjD,IAAA;AAOa,IAAA;AACzB,MAAA;AACC,MAAA;AACV,IAAA;AACH,EAAA;AACF;AA0DqD;AACjB,EAAA;AACH,IAAA;AAC9B,EAAA;AAEmD,EAAA;AAG3B,EAAA;AACF,IAAA;AACvB,EAAA;AACF;ALwSsD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/index.cjs","sourcesContent":[null,"import {\n EIP7702StatelessDeleGator,\n HybridDeleGator,\n MultiSigDeleGator,\n} from '@metamask/delegation-abis';\nimport { type Address, type Hex } from 'viem';\nimport {\n entryPoint07Abi,\n toPackedUserOperation,\n toSmartAccount,\n} from 'viem/account-abstraction';\n\nimport { isValid7702Implementation } from './actions/isValid7702Implementation';\nimport { trackSmartAccountsKitFunctionCall } from './analytics';\nimport { Implementation } from './constants';\nimport { getCounterfactualAccountData } from './counterfactualAccountData';\nimport {\n SIGNABLE_DELEGATION_TYPED_DATA,\n toDelegationStruct,\n} from './delegation';\nimport { encodeCallsForCaller } from './encodeCalls';\nimport { resolveSigner } from './signer';\nimport { getSmartAccountsEnvironment } from './smartAccountsEnvironment';\nimport type {\n Call,\n ToMetaMaskSmartAccountParameters,\n ToMetaMaskSmartAccountReturnType,\n SignDelegationParams,\n SignUserOperationParams,\n AbiByImplementation,\n} from './types';\nimport { SIGNABLE_USER_OP_TYPED_DATA } from './userOp';\n\nconst ENTRYPOINT_VERSION = '0.7' as const;\n\n/**\n * Creates a MetaMask DeleGator smart account instance.\n *\n * @template TImplementation - The type of implementation, extending Implementation.\n * @param params - The parameters for creating the smart account.\n * @returns A promise that resolves to a MetaMaskSmartAccount instance.\n * @description\n * This function sets up a MetaMask DeleGator smart account with the specified implementation.\n * It handles both deployed accounts, and counterfactual accounts.\n * A caller may specify a SmartAccountsEnvironment, otherwise the environment will be inferred from the chain.\n */\nexport async function toMetaMaskSmartAccount<\n TImplementation extends Implementation,\n>(\n params: ToMetaMaskSmartAccountParameters<TImplementation>,\n): Promise<ToMetaMaskSmartAccountReturnType<TImplementation>> {\n const {\n client,\n client: { chain },\n implementation,\n nonceKeyManager,\n } = params;\n\n trackSmartAccountsKitFunctionCall('toMetaMaskSmartAccount', {\n implementation,\n hasAddress: params.address !== undefined,\n hasEnvironment: params.environment !== undefined,\n chainId: chain?.id ?? null,\n });\n\n if (!chain) {\n throw new Error('Chain not specified');\n }\n\n const signer = resolveSigner({\n implementation,\n signer: params.signer,\n });\n\n const environment =\n params.environment ?? getSmartAccountsEnvironment(chain.id);\n\n let address: Address, factoryData: Hex | undefined;\n\n if (params.address) {\n factoryData = undefined;\n address = params.address;\n } else {\n if (implementation === Implementation.Stateless7702) {\n throw new Error('Stateless7702 does not support counterfactual accounts');\n }\n\n const accountData = await getCounterfactualAccountData({\n factory: environment.SimpleFactory,\n implementations: environment.implementations,\n implementation,\n deployParams: params.deployParams,\n deploySalt: params.deploySalt,\n });\n\n address = accountData.address;\n factoryData = accountData.factoryData;\n }\n\n const entryPoint = {\n abi: entryPoint07Abi,\n address: environment.EntryPoint,\n version: ENTRYPOINT_VERSION,\n } as const;\n\n const { abi, contractName } = {\n [Implementation.Hybrid]: {\n contractName: 'HybridDeleGator',\n abi: HybridDeleGator,\n },\n [Implementation.MultiSig]: {\n contractName: 'MultiSigDeleGator',\n abi: MultiSigDeleGator,\n },\n [Implementation.Stateless7702]: {\n contractName: 'EIP7702StatelessDeleGator',\n abi: EIP7702StatelessDeleGator,\n },\n }[implementation] as {\n contractName: string;\n abi: AbiByImplementation[TImplementation];\n };\n\n const getFactoryArgs = async () => {\n if (factoryData === undefined) {\n throw new Error(\n 'Deploy params were not provided, so factory args cannot be inferred',\n );\n }\n return {\n factoryData,\n factory: environment.SimpleFactory,\n };\n };\n\n const signDelegation = async (delegationParams: SignDelegationParams) => {\n if (!signer) {\n throw new Error(\n 'Cannot sign delegation: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations.',\n );\n }\n\n const { delegation, chainId } = delegationParams;\n\n const delegationStruct = toDelegationStruct({\n ...delegation,\n signature: '0x',\n });\n\n const signature = await signer.signTypedData({\n domain: {\n chainId: chainId ?? chain.id,\n name: 'DelegationManager',\n version: '1',\n verifyingContract: environment.DelegationManager,\n },\n types: SIGNABLE_DELEGATION_TYPED_DATA,\n primaryType: 'Delegation',\n message: delegationStruct,\n });\n\n return signature;\n };\n\n const signUserOperation = async (userOpParams: SignUserOperationParams) => {\n if (!signer) {\n throw new Error(\n 'Cannot sign user operation: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations.',\n );\n }\n\n const { chainId } = userOpParams;\n\n const packedUserOp = toPackedUserOperation({\n sender: address,\n ...userOpParams,\n signature: '0x',\n });\n\n const signature = await signer.signTypedData({\n domain: {\n chainId: chainId ?? chain.id,\n name: contractName,\n version: '1',\n verifyingContract: address,\n },\n types: SIGNABLE_USER_OP_TYPED_DATA,\n primaryType: 'PackedUserOperation',\n message: { ...packedUserOp, entryPoint: entryPoint.address },\n });\n\n return signature;\n };\n\n const getAddress = async () => address;\n\n const encodeCalls = async (calls: readonly Call[]) =>\n encodeCallsForCaller(address, calls);\n\n const signerMethods = signer ?? {\n signMessage: async () => {\n throw new Error(\n 'Cannot sign message: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations.',\n );\n },\n signTypedData: async () => {\n throw new Error(\n 'Cannot sign typed data: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations.',\n );\n },\n getStubSignature: async () => {\n throw new Error(\n 'Cannot get stub signature: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations.',\n );\n },\n };\n\n const smartAccount = await toSmartAccount({\n abi,\n client,\n entryPoint,\n environment,\n getAddress,\n getFactoryArgs,\n encodeCalls,\n signUserOperation,\n signDelegation,\n nonceKeyManager,\n ...signerMethods,\n });\n\n // Override isDeployed only for EIP-7702 implementation to check proper delegation code\n if (implementation === Implementation.Stateless7702) {\n return {\n ...smartAccount,\n isDeployed: async () =>\n isValid7702Implementation({\n client,\n accountAddress: address,\n environment,\n }),\n };\n }\n\n // For other implementations, use the default isDeployed behavior\n return smartAccount;\n}\n","import { concat } from 'viem';\nimport type {\n Address,\n SignableMessage,\n TypedData,\n TypedDataDefinition,\n} from 'viem';\nimport type { WebAuthnAccount } from 'viem/account-abstraction';\n\nimport { Implementation } from './constants';\nimport { aggregateSignature } from './signatures';\nimport type {\n AccountSignerConfig,\n HybridSignerConfig,\n InternalSigner,\n MultiSigSignerConfig,\n SignerConfigByImplementation,\n Stateless7702SignerConfig,\n WalletSignerConfig,\n} from './types';\nimport {\n createDummyWebAuthnSignature,\n encodeDeleGatorSignature,\n} from './webAuthn';\n\n// A valid ECDSA signature, this must be able to ecrecover an address, otherwise the contracts will revert in isValidSignature\nconst EOA_STUB_SIGNATURE =\n '0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000011b' as const;\n\nconst resolveSignerFromWalletConfig = (\n config: WalletSignerConfig,\n): InternalSigner => {\n return {\n signMessage: config.walletClient.signMessage,\n signTypedData: async (typedData) => {\n // todo: figure out this type so that we don't need the type assertion\n return config.walletClient.signTypedData(typedData as any);\n },\n getStubSignature: async () => EOA_STUB_SIGNATURE,\n };\n};\n\nconst resolveSignerFromAccountConfig = (config: AccountSignerConfig) => {\n return {\n signMessage: config.account.signMessage,\n signTypedData: config.account.signTypedData,\n getStubSignature: async () => EOA_STUB_SIGNATURE,\n };\n};\n\nconst resolveHybridSigner = (config: HybridSignerConfig): InternalSigner => {\n if ('walletClient' in config) {\n return resolveSignerFromWalletConfig(config);\n } else if ('account' in config) {\n const { signMessage, signTypedData, getStubSignature } =\n resolveSignerFromAccountConfig(config);\n if (!signMessage) {\n throw new Error('Account does not support signMessage');\n }\n if (!signTypedData) {\n throw new Error('Account does not support signTypedData');\n }\n return {\n signMessage,\n signTypedData,\n getStubSignature,\n };\n }\n const { keyId, webAuthnAccount } = config;\n\n if (webAuthnAccount.type !== 'webAuthn') {\n throw new Error('Account is not a webAuthn account');\n }\n\n const encodeSignature = (\n result: Awaited<ReturnType<WebAuthnAccount['signMessage']>>,\n ) =>\n encodeDeleGatorSignature(\n keyId,\n result.signature,\n result.webauthn.clientDataJSON,\n result.webauthn.authenticatorData,\n );\n\n const signMessage = async (args: { message: SignableMessage }) =>\n webAuthnAccount.signMessage(args).then(encodeSignature);\n const signTypedData = async <\n const TTypedData extends TypedData | Record<string, unknown>,\n TPrimaryType extends keyof TTypedData | 'EIP712Domain' = keyof TTypedData,\n >(\n typedDataDefinition: TypedDataDefinition<TTypedData, TPrimaryType>,\n ) => webAuthnAccount.signTypedData(typedDataDefinition).then(encodeSignature);\n\n const getStubSignature = async () => createDummyWebAuthnSignature(keyId);\n\n return {\n signMessage,\n signTypedData,\n getStubSignature,\n };\n};\n\nconst resolveMultiSigSigner = (\n config: MultiSigSignerConfig,\n): InternalSigner => {\n const resolvedSigners = config.map((signer) => {\n let individualSignMessage: InternalSigner['signMessage'];\n let individualSignTypedData: InternalSigner['signTypedData'];\n let address: Address;\n if ('walletClient' in signer) {\n const { signMessage, signTypedData } =\n resolveSignerFromWalletConfig(signer);\n individualSignMessage = signMessage;\n individualSignTypedData = signTypedData;\n\n address = signer.walletClient.account.address;\n } else {\n const { signMessage, signTypedData } =\n resolveSignerFromAccountConfig(signer);\n if (!signMessage) {\n throw new Error('Account does not support signMessage');\n }\n if (!signTypedData) {\n throw new Error('Account does not support signTypedData');\n }\n\n individualSignMessage = signMessage;\n individualSignTypedData = signTypedData;\n\n address = signer.account.address;\n }\n return {\n address,\n individualSignMessage,\n individualSignTypedData,\n };\n });\n\n const signMessage = async (args: { message: SignableMessage }) => {\n const addressAndSignatures = resolvedSigners.map(\n async ({ individualSignMessage, address }) => ({\n signature: await individualSignMessage(args),\n signer: address,\n type: 'ECDSA' as const,\n }),\n );\n\n const signatures = await Promise.all(addressAndSignatures);\n\n return aggregateSignature({\n signatures,\n });\n };\n\n const signTypedData = async <\n const TTypedData extends TypedData | Record<string, unknown>,\n TPrimaryType extends keyof TTypedData | 'EIP712Domain' = keyof TTypedData,\n >(\n typedDataDefinition: TypedDataDefinition<TTypedData, TPrimaryType>,\n ) => {\n const addressAndSignatures = resolvedSigners.map(\n async ({ individualSignTypedData, address }) => ({\n signature: await individualSignTypedData(typedDataDefinition),\n signer: address,\n type: 'ECDSA' as const,\n }),\n );\n\n const signatures = await Promise.all(addressAndSignatures);\n\n return aggregateSignature({\n signatures,\n });\n };\n\n const getStubSignature = async () =>\n concat(resolvedSigners.map(() => EOA_STUB_SIGNATURE));\n\n return {\n signMessage,\n signTypedData,\n getStubSignature,\n };\n};\n\nconst resolveStateless7702Signer = (\n config: Stateless7702SignerConfig,\n): InternalSigner => {\n if ('walletClient' in config) {\n return resolveSignerFromWalletConfig(config);\n } else if ('account' in config) {\n const { signMessage, signTypedData, getStubSignature } =\n resolveSignerFromAccountConfig(config);\n if (!signMessage) {\n throw new Error('Account does not support signMessage');\n }\n if (!signTypedData) {\n throw new Error('Account does not support signTypedData');\n }\n\n return {\n signMessage,\n signTypedData,\n getStubSignature,\n };\n }\n\n throw new Error('Invalid signer config');\n};\n\n/**\n * Resolve a signer from a configuration object.\n *\n * @param config - The configuration object.\n * @param config.implementation - The implementation type.\n * @param config.signer - The signer configuration object.\n * @returns The resolved signer.\n */\nexport function resolveSigner<TImplementation extends Implementation>(config: {\n implementation: TImplementation;\n signer: SignerConfigByImplementation<TImplementation>;\n}): InternalSigner;\n\n/**\n * Resolve a signer from a configuration object. If no signer is provided, return null.\n *\n * @param config - The configuration object.\n * @param config.implementation - The implementation type.\n * @param config.signer - The signer configuration object.\n * @returns The resolved signer or null if no signer is provided.\n */\nexport function resolveSigner<TImplementation extends Implementation>(config: {\n implementation: TImplementation;\n signer?: SignerConfigByImplementation<TImplementation>;\n}): InternalSigner | null;\n\n/**\n * Resolve a signer from a configuration object. If no signer is provided, return null.\n *\n * @param config - The configuration object.\n * @param config.implementation - The implementation type.\n * @param config.signer - The signer configuration object.\n * @returns The resolved signer or null if no signer is provided.\n */\nexport function resolveSigner<TImplementation extends Implementation>(config: {\n implementation: TImplementation;\n signer?: SignerConfigByImplementation<TImplementation>;\n}): InternalSigner | null {\n const { implementation, signer } = config;\n\n if (!signer) {\n return null;\n }\n\n if (implementation === Implementation.Hybrid) {\n return resolveHybridSigner(signer as HybridSignerConfig);\n } else if (implementation === Implementation.MultiSig) {\n return resolveMultiSigSigner(signer as MultiSigSignerConfig);\n } else if (implementation === Implementation.Stateless7702) {\n return resolveStateless7702Signer(signer as Stateless7702SignerConfig);\n }\n throw new Error(`Implementation type '${implementation}' not supported`);\n}\n","import type { Address, Hex } from 'viem';\nimport { concat } from 'viem';\n\nimport { trackSmartAccountsKitFunctionCall } from './analytics';\n\nconst signatureTypes = ['ECDSA'] as const;\n\nexport type SignatureType = (typeof signatureTypes)[number];\n\n/**\n * Represents a partial signature that can be aggregated with others.\n */\nexport type PartialSignature = {\n signer: Address;\n signature: Hex;\n type: SignatureType;\n};\n\n/**\n * Aggregates signatures into a single signature as expected by the MultiSig implementation.\n *\n * @param params - The parameters for signature aggregation.\n * @param params.signatures - The array of partial signatures to aggregate.\n * @returns The aggregated signature.\n */\nexport const aggregateSignature = ({\n signatures,\n}: {\n signatures: PartialSignature[];\n}): Hex => {\n trackSmartAccountsKitFunctionCall('aggregateSignature', {\n signatureCount: signatures.length,\n });\n\n if (signatures.length === 0) {\n return '0x';\n }\n\n for (const { type } of signatures) {\n if (!signatureTypes.includes(type)) {\n throw new Error(`Invalid signature type: ${type}`);\n }\n }\n\n // Sort signatures by signer address as required by MultiSig implementation\n const sortedSignatures = [...signatures].sort((a, b) =>\n a.signer.localeCompare(b.signer),\n );\n\n // Concatenate all signatures\n return concat(sortedSignatures.map(({ signature }) => signature));\n};\n\n/**\n * Type definition for the aggregateSignature function parameters.\n */\nexport type AggregateSignatureParams = {\n signatures: PartialSignature[];\n};\n","import type { Client, Transport, Chain, Account } from 'viem';\n\nimport { trackSmartAccountsKitFunctionCall } from '../analytics';\nimport type { SmartAccountsEnvironment } from '../types';\nimport {\n caveatEnforcerActions,\n type CaveatEnforcerParams,\n type PeriodTransferResult,\n type StreamingResult,\n} from './getCaveatAvailableAmount';\n\n/**\n * Type for client extended with caveat enforcer actions.\n */\nexport type CaveatEnforcerClient<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends Account | undefined = Account | undefined,\n> = Client<TTransport, TChain, TAccount> &\n ReturnType<ReturnType<typeof caveatEnforcerActions>>;\n\n/**\n * Create a viem client extended with caveat enforcer actions.\n *\n * @param params - The parameters object.\n * @param params.client - The viem client.\n * @param params.environment - The SmartAccountsEnvironment.\n * @returns The extended client with caveat enforcer actions.\n */\nexport function createCaveatEnforcerClient<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends Account | undefined = Account | undefined,\n>({\n client,\n environment,\n}: {\n client: Client<TTransport, TChain, TAccount>;\n environment: SmartAccountsEnvironment;\n}): CaveatEnforcerClient<TTransport, TChain, TAccount> {\n trackSmartAccountsKitFunctionCall('createCaveatEnforcerClient', {\n chainId: client.chain?.id ?? null,\n });\n\n return client.extend(caveatEnforcerActions({ environment }));\n}\n\n// Re-export types for convenience\nexport type { CaveatEnforcerParams, PeriodTransferResult, StreamingResult };\n","import type { Transport, Chain, Hex, Client, Account } from 'viem';\nimport {\n createBundlerClient,\n type BundlerClient,\n type BundlerClientConfig,\n type SmartAccount,\n} from 'viem/account-abstraction';\n\nimport { trackSmartAccountsKitFunctionCall } from '../analytics';\n\n/**\n * Gas price tiers returned by pimlico_getUserOperationGasPrice\n */\nexport type GasPriceTier = {\n /** Maximum fee per gas in hex format */\n maxFeePerGas: Hex;\n /** Maximum priority fee per gas in hex format */\n maxPriorityFeePerGas: Hex;\n};\n\n/**\n * Response from pimlico_getUserOperationGasPrice RPC method\n */\nexport type UserOperationGasPriceResponse = {\n /** Slow gas price tier */\n slow: GasPriceTier;\n /** Standard gas price tier */\n standard: GasPriceTier;\n /** Fast gas price tier */\n fast: GasPriceTier;\n};\n\n/**\n * Pimlico bundler schema for type-safe RPC method calls\n */\n/* eslint-disable @typescript-eslint/naming-convention */\ntype PimlicoBundlerSchema = [\n {\n Method: 'pimlico_getUserOperationGasPrice';\n Parameters: [];\n ReturnType: UserOperationGasPriceResponse;\n },\n];\n\n/**\n * Infura bundler actions for extending bundler clients.\n *\n * @returns A function that takes a client and returns the client extension with Infura bundler actions.\n */\nconst infuraBundlerActions = () => (client: Client) => ({\n /**\n * Get user operation gas prices from Infura bundler.\n * Calls the pimlico_getUserOperationGasPrice RPC method.\n *\n * @returns Promise resolving to gas price tiers (slow, standard, fast).\n * @example\n * ```typescript\n * const gasPrices = await bundlerClient.getUserOperationGasPrice();\n * console.log(gasPrices.standard.maxFeePerGas);\n * ```\n */\n async getUserOperationGasPrice(): Promise<UserOperationGasPriceResponse> {\n const pimlicoClient = client as Client<\n Transport,\n Chain | undefined,\n Account | undefined,\n PimlicoBundlerSchema\n >;\n\n return await pimlicoClient.request({\n method: 'pimlico_getUserOperationGasPrice',\n params: [],\n });\n },\n});\n\n/**\n * Type for bundler client extended with Infura bundler actions.\n */\nexport type InfuraBundlerClient<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartAccount | undefined = SmartAccount | undefined,\n> = BundlerClient<TTransport, TChain, TAccount> & {\n /**\n * Get user operation gas prices from Infura bundler.\n * Calls the pimlico_getUserOperationGasPrice RPC method.\n *\n * @returns Promise resolving to gas price tiers (slow, standard, fast).\n */\n getUserOperationGasPrice(): Promise<UserOperationGasPriceResponse>;\n};\n\n/**\n * Creates an Infura bundler client extended with Infura bundler actions.\n *\n * This is a wrapper around viem's createBundlerClient that extends it with\n * the getUserOperationGasPrice method for retrieving gas prices from Pimlico's\n * bundler infrastructure via Infura's proxy.\n *\n * @param config - Configuration for the bundler client.\n * @returns Extended bundler client with Infura bundler actions.\n * @example\n * ```typescript\n * import { createPublicClient, http } from 'viem';\n * import { sepolia } from 'viem/chains';\n * import { createInfuraBundlerClient } from '@metamask/smart-accounts-kit';\n *\n * const publicClient = createPublicClient({\n * chain: sepolia,\n * transport: http('https://sepolia.infura.io/v3/YOUR_API_KEY'),\n * });\n *\n * const bundlerClient = createInfuraBundlerClient({\n * client: publicClient,\n * transport: http('https://sepolia.infura.io/v3/YOUR_API_KEY'),\n * chain: sepolia,\n * });\n *\n * // Use standard bundler methods\n * const userOpHash = await bundlerClient.sendUserOperation({...});\n *\n * // Use Infura specific methods\n * const gasPrices = await bundlerClient.getUserOperationGasPrice();\n * ```\n */\nexport function createInfuraBundlerClient<\n TTransport extends Transport,\n TChain extends Chain | undefined = undefined,\n TAccount extends SmartAccount | undefined = undefined,\n>(\n config: BundlerClientConfig<TTransport, TChain, TAccount>,\n): InfuraBundlerClient<TTransport, TChain, TAccount> {\n trackSmartAccountsKitFunctionCall('createInfuraBundlerClient', {\n chainId: config.chain?.id ?? null,\n });\n // Create the base bundler client using viem's function\n const baseBundlerClient = createBundlerClient(config);\n\n // Extend the client with Infura bundler actions\n return baseBundlerClient.extend(\n infuraBundlerActions(),\n ) as unknown as InfuraBundlerClient<TTransport, TChain, TAccount>;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/index.cjs","../src/toMetaMaskSmartAccount.ts","../src/signer.ts","../src/signatures.ts","../src/index.ts","../src/actions/caveatEnforcerClient.ts","../src/actions/infuraBundlerClient.ts"],"names":["signTypedData","signMessage","getStubSignature","signUserOperation","signDelegation"],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;AC1CA;AACE;AACA;AACA;AAAA,2DACK;AAEP;AACE;AACA;AACA;AAAA,8DACK;AD2CP;AACA;AEtDA,4BAAuB;AFwDvB;AACA;AGxDA;AAIA,IAAM,eAAA,EAAiB,CAAC,OAAO,CAAA;AAoBxB,IAAM,mBAAA,EAAqB,CAAC;AAAA,EACjC;AACF,CAAA,EAAA,GAEW;AACT,EAAA,iEAAA,oBAAkC,EAAsB;AAAA,IACtD,cAAA,EAAgB,UAAA,CAAW;AAAA,EAC7B,CAAC,CAAA;AAED,EAAA,GAAA,CAAI,UAAA,CAAW,OAAA,IAAW,CAAA,EAAG;AAC3B,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,IAAA,CAAA,MAAW,EAAE,KAAK,EAAA,GAAK,UAAA,EAAY;AACjC,IAAA,GAAA,CAAI,CAAC,cAAA,CAAe,QAAA,CAAS,IAAI,CAAA,EAAG;AAClC,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,wBAAA,EAA2B,IAAI,CAA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ACA;AK5WpD;AACA,EAAA;AACA,EAAA;AAIqD;AACnB,EAAA;AACH,IAAA;AAC9B,EAAA;AAE4C,EAAA;AAC/C;AL0WsD;AACA;AMvZtD;AACE;AAIK;AA2CiD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYmB,EAAA;AACjD,IAAA;AAOa,IAAA;AACzB,MAAA;AACC,MAAA;AACV,IAAA;AACH,EAAA;AACF;AA0DqD;AACjB,EAAA;AACH,IAAA;AAC9B,EAAA;AAEmD,EAAA;AAG3B,EAAA;AACF,IAAA;AACvB,EAAA;AACF;AN0SsD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/smart-accounts-kit/smart-accounts-kit/packages/smart-accounts-kit/dist/index.cjs","sourcesContent":[null,"import {\n EIP7702StatelessDeleGator,\n HybridDeleGator,\n MultiSigDeleGator,\n} from '@metamask/delegation-abis';\nimport { type Address, type Hex } from 'viem';\nimport {\n entryPoint07Abi,\n toPackedUserOperation,\n toSmartAccount,\n} from 'viem/account-abstraction';\n\nimport { isValid7702Implementation } from './actions/isValid7702Implementation';\nimport { trackSmartAccountsKitFunctionCall } from './analytics';\nimport { Implementation } from './constants';\nimport { getCounterfactualAccountData } from './counterfactualAccountData';\nimport {\n SIGNABLE_DELEGATION_TYPED_DATA,\n toDelegationStruct,\n} from './delegation';\nimport { encodeCallsForCaller } from './encodeCalls';\nimport { resolveSigner } from './signer';\nimport { getSmartAccountsEnvironment } from './smartAccountsEnvironment';\nimport type {\n Call,\n ToMetaMaskSmartAccountParameters,\n ToMetaMaskSmartAccountReturnType,\n SignDelegationParams,\n SignUserOperationParams,\n AbiByImplementation,\n} from './types';\nimport { SIGNABLE_USER_OP_TYPED_DATA } from './userOp';\n\nconst ENTRYPOINT_VERSION = '0.7' as const;\n\n/**\n * Creates a MetaMask DeleGator smart account instance.\n *\n * @template TImplementation - The type of implementation, extending Implementation.\n * @param params - The parameters for creating the smart account.\n * @returns A promise that resolves to a MetaMaskSmartAccount instance.\n * @description\n * This function sets up a MetaMask DeleGator smart account with the specified implementation.\n * It handles both deployed accounts, and counterfactual accounts.\n * A caller may specify a SmartAccountsEnvironment, otherwise the environment will be inferred from the chain.\n */\nexport async function toMetaMaskSmartAccount<\n TImplementation extends Implementation,\n>(\n params: ToMetaMaskSmartAccountParameters<TImplementation>,\n): Promise<ToMetaMaskSmartAccountReturnType<TImplementation>> {\n const {\n client,\n client: { chain },\n implementation,\n nonceKeyManager,\n } = params;\n\n trackSmartAccountsKitFunctionCall('toMetaMaskSmartAccount', {\n implementation,\n hasAddress: params.address !== undefined,\n hasEnvironment: params.environment !== undefined,\n chainId: chain?.id ?? null,\n });\n\n if (!chain) {\n throw new Error('Chain not specified');\n }\n\n const signer = resolveSigner({\n implementation,\n signer: params.signer,\n });\n\n const environment =\n params.environment ?? getSmartAccountsEnvironment(chain.id);\n\n let address: Address, factoryData: Hex | undefined;\n\n if (params.address) {\n factoryData = undefined;\n address = params.address;\n } else {\n if (implementation === Implementation.Stateless7702) {\n throw new Error('Stateless7702 does not support counterfactual accounts');\n }\n\n const accountData = await getCounterfactualAccountData({\n factory: environment.SimpleFactory,\n implementations: environment.implementations,\n implementation,\n deployParams: params.deployParams,\n deploySalt: params.deploySalt,\n });\n\n address = accountData.address;\n factoryData = accountData.factoryData;\n }\n\n const entryPoint = {\n abi: entryPoint07Abi,\n address: environment.EntryPoint,\n version: ENTRYPOINT_VERSION,\n } as const;\n\n const { abi, contractName } = {\n [Implementation.Hybrid]: {\n contractName: 'HybridDeleGator',\n abi: HybridDeleGator,\n },\n [Implementation.MultiSig]: {\n contractName: 'MultiSigDeleGator',\n abi: MultiSigDeleGator,\n },\n [Implementation.Stateless7702]: {\n contractName: 'EIP7702StatelessDeleGator',\n abi: EIP7702StatelessDeleGator,\n },\n }[implementation] as {\n contractName: string;\n abi: AbiByImplementation[TImplementation];\n };\n\n const getFactoryArgs = async () => {\n if (factoryData === undefined) {\n throw new Error(\n 'Deploy params were not provided, so factory args cannot be inferred',\n );\n }\n return {\n factoryData,\n factory: environment.SimpleFactory,\n };\n };\n\n const signDelegation = async (delegationParams: SignDelegationParams) => {\n if (!signer) {\n throw new Error(\n 'Cannot sign delegation: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations.',\n );\n }\n\n const { delegation, chainId } = delegationParams;\n\n const delegationStruct = toDelegationStruct({\n ...delegation,\n signature: '0x',\n });\n\n const signature = await signer.signTypedData({\n domain: {\n chainId: chainId ?? chain.id,\n name: 'DelegationManager',\n version: '1',\n verifyingContract: environment.DelegationManager,\n },\n types: SIGNABLE_DELEGATION_TYPED_DATA,\n primaryType: 'Delegation',\n message: delegationStruct,\n });\n\n return signature;\n };\n\n const signUserOperation = async (userOpParams: SignUserOperationParams) => {\n if (!signer) {\n throw new Error(\n 'Cannot sign user operation: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations.',\n );\n }\n\n const { chainId } = userOpParams;\n\n const packedUserOp = toPackedUserOperation({\n sender: address,\n ...userOpParams,\n signature: '0x',\n });\n\n const signature = await signer.signTypedData({\n domain: {\n chainId: chainId ?? chain.id,\n name: contractName,\n version: '1',\n verifyingContract: address,\n },\n types: SIGNABLE_USER_OP_TYPED_DATA,\n primaryType: 'PackedUserOperation',\n message: { ...packedUserOp, entryPoint: entryPoint.address },\n });\n\n return signature;\n };\n\n const getAddress = async () => address;\n\n const encodeCalls = async (calls: readonly Call[]) =>\n encodeCallsForCaller(address, calls);\n\n const signerMethods = signer ?? {\n signMessage: async () => {\n throw new Error(\n 'Cannot sign message: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations.',\n );\n },\n signTypedData: async () => {\n throw new Error(\n 'Cannot sign typed data: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations.',\n );\n },\n getStubSignature: async () => {\n throw new Error(\n 'Cannot get stub signature: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations.',\n );\n },\n };\n\n const smartAccount = await toSmartAccount({\n abi,\n client,\n entryPoint,\n environment,\n getAddress,\n getFactoryArgs,\n encodeCalls,\n signUserOperation,\n signDelegation,\n nonceKeyManager,\n ...signerMethods,\n });\n\n // Override isDeployed only for EIP-7702 implementation to check proper delegation code\n if (implementation === Implementation.Stateless7702) {\n return {\n ...smartAccount,\n isDeployed: async () =>\n isValid7702Implementation({\n client,\n accountAddress: address,\n environment,\n }),\n };\n }\n\n // For other implementations, use the default isDeployed behavior\n return smartAccount;\n}\n","import { concat } from 'viem';\nimport type {\n Address,\n SignableMessage,\n TypedData,\n TypedDataDefinition,\n} from 'viem';\nimport type { WebAuthnAccount } from 'viem/account-abstraction';\n\nimport { Implementation } from './constants';\nimport { aggregateSignature } from './signatures';\nimport type {\n AccountSignerConfig,\n HybridSignerConfig,\n InternalSigner,\n MultiSigSignerConfig,\n SignerConfigByImplementation,\n Stateless7702SignerConfig,\n WalletSignerConfig,\n} from './types';\nimport {\n createDummyWebAuthnSignature,\n encodeDeleGatorSignature,\n} from './webAuthn';\n\n// A valid ECDSA signature, this must be able to ecrecover an address, otherwise the contracts will revert in isValidSignature\nconst EOA_STUB_SIGNATURE =\n '0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000011b' as const;\n\nconst resolveSignerFromWalletConfig = (\n config: WalletSignerConfig,\n): InternalSigner => {\n return {\n signMessage: config.walletClient.signMessage,\n signTypedData: async (typedData) => {\n // todo: figure out this type so that we don't need the type assertion\n return config.walletClient.signTypedData(typedData as any);\n },\n getStubSignature: async () => EOA_STUB_SIGNATURE,\n };\n};\n\nconst resolveSignerFromAccountConfig = (config: AccountSignerConfig) => {\n return {\n signMessage: config.account.signMessage,\n signTypedData: config.account.signTypedData,\n getStubSignature: async () => EOA_STUB_SIGNATURE,\n };\n};\n\nconst resolveHybridSigner = (config: HybridSignerConfig): InternalSigner => {\n if ('walletClient' in config) {\n return resolveSignerFromWalletConfig(config);\n } else if ('account' in config) {\n const { signMessage, signTypedData, getStubSignature } =\n resolveSignerFromAccountConfig(config);\n if (!signMessage) {\n throw new Error('Account does not support signMessage');\n }\n if (!signTypedData) {\n throw new Error('Account does not support signTypedData');\n }\n return {\n signMessage,\n signTypedData,\n getStubSignature,\n };\n }\n const { keyId, webAuthnAccount } = config;\n\n if (webAuthnAccount.type !== 'webAuthn') {\n throw new Error('Account is not a webAuthn account');\n }\n\n const encodeSignature = (\n result: Awaited<ReturnType<WebAuthnAccount['signMessage']>>,\n ) =>\n encodeDeleGatorSignature(\n keyId,\n result.signature,\n result.webauthn.clientDataJSON,\n result.webauthn.authenticatorData,\n );\n\n const signMessage = async (args: { message: SignableMessage }) =>\n webAuthnAccount.signMessage(args).then(encodeSignature);\n const signTypedData = async <\n const TTypedData extends TypedData | Record<string, unknown>,\n TPrimaryType extends keyof TTypedData | 'EIP712Domain' = keyof TTypedData,\n >(\n typedDataDefinition: TypedDataDefinition<TTypedData, TPrimaryType>,\n ) => webAuthnAccount.signTypedData(typedDataDefinition).then(encodeSignature);\n\n const getStubSignature = async () => createDummyWebAuthnSignature(keyId);\n\n return {\n signMessage,\n signTypedData,\n getStubSignature,\n };\n};\n\nconst resolveMultiSigSigner = (\n config: MultiSigSignerConfig,\n): InternalSigner => {\n const resolvedSigners = config.map((signer) => {\n let individualSignMessage: InternalSigner['signMessage'];\n let individualSignTypedData: InternalSigner['signTypedData'];\n let address: Address;\n if ('walletClient' in signer) {\n const { signMessage, signTypedData } =\n resolveSignerFromWalletConfig(signer);\n individualSignMessage = signMessage;\n individualSignTypedData = signTypedData;\n\n address = signer.walletClient.account.address;\n } else {\n const { signMessage, signTypedData } =\n resolveSignerFromAccountConfig(signer);\n if (!signMessage) {\n throw new Error('Account does not support signMessage');\n }\n if (!signTypedData) {\n throw new Error('Account does not support signTypedData');\n }\n\n individualSignMessage = signMessage;\n individualSignTypedData = signTypedData;\n\n address = signer.account.address;\n }\n return {\n address,\n individualSignMessage,\n individualSignTypedData,\n };\n });\n\n const signMessage = async (args: { message: SignableMessage }) => {\n const addressAndSignatures = resolvedSigners.map(\n async ({ individualSignMessage, address }) => ({\n signature: await individualSignMessage(args),\n signer: address,\n type: 'ECDSA' as const,\n }),\n );\n\n const signatures = await Promise.all(addressAndSignatures);\n\n return aggregateSignature({\n signatures,\n });\n };\n\n const signTypedData = async <\n const TTypedData extends TypedData | Record<string, unknown>,\n TPrimaryType extends keyof TTypedData | 'EIP712Domain' = keyof TTypedData,\n >(\n typedDataDefinition: TypedDataDefinition<TTypedData, TPrimaryType>,\n ) => {\n const addressAndSignatures = resolvedSigners.map(\n async ({ individualSignTypedData, address }) => ({\n signature: await individualSignTypedData(typedDataDefinition),\n signer: address,\n type: 'ECDSA' as const,\n }),\n );\n\n const signatures = await Promise.all(addressAndSignatures);\n\n return aggregateSignature({\n signatures,\n });\n };\n\n const getStubSignature = async () =>\n concat(resolvedSigners.map(() => EOA_STUB_SIGNATURE));\n\n return {\n signMessage,\n signTypedData,\n getStubSignature,\n };\n};\n\nconst resolveStateless7702Signer = (\n config: Stateless7702SignerConfig,\n): InternalSigner => {\n if ('walletClient' in config) {\n return resolveSignerFromWalletConfig(config);\n } else if ('account' in config) {\n const { signMessage, signTypedData, getStubSignature } =\n resolveSignerFromAccountConfig(config);\n if (!signMessage) {\n throw new Error('Account does not support signMessage');\n }\n if (!signTypedData) {\n throw new Error('Account does not support signTypedData');\n }\n\n return {\n signMessage,\n signTypedData,\n getStubSignature,\n };\n }\n\n throw new Error('Invalid signer config');\n};\n\n/**\n * Resolve a signer from a configuration object.\n *\n * @param config - The configuration object.\n * @param config.implementation - The implementation type.\n * @param config.signer - The signer configuration object.\n * @returns The resolved signer.\n */\nexport function resolveSigner<TImplementation extends Implementation>(config: {\n implementation: TImplementation;\n signer: SignerConfigByImplementation<TImplementation>;\n}): InternalSigner;\n\n/**\n * Resolve a signer from a configuration object. If no signer is provided, return null.\n *\n * @param config - The configuration object.\n * @param config.implementation - The implementation type.\n * @param config.signer - The signer configuration object.\n * @returns The resolved signer or null if no signer is provided.\n */\nexport function resolveSigner<TImplementation extends Implementation>(config: {\n implementation: TImplementation;\n signer?: SignerConfigByImplementation<TImplementation>;\n}): InternalSigner | null;\n\n/**\n * Resolve a signer from a configuration object. If no signer is provided, return null.\n *\n * @param config - The configuration object.\n * @param config.implementation - The implementation type.\n * @param config.signer - The signer configuration object.\n * @returns The resolved signer or null if no signer is provided.\n */\nexport function resolveSigner<TImplementation extends Implementation>(config: {\n implementation: TImplementation;\n signer?: SignerConfigByImplementation<TImplementation>;\n}): InternalSigner | null {\n const { implementation, signer } = config;\n\n if (!signer) {\n return null;\n }\n\n if (implementation === Implementation.Hybrid) {\n return resolveHybridSigner(signer as HybridSignerConfig);\n } else if (implementation === Implementation.MultiSig) {\n return resolveMultiSigSigner(signer as MultiSigSignerConfig);\n } else if (implementation === Implementation.Stateless7702) {\n return resolveStateless7702Signer(signer as Stateless7702SignerConfig);\n }\n throw new Error(`Implementation type '${implementation}' not supported`);\n}\n","import type { Address, Hex } from 'viem';\nimport { concat } from 'viem';\n\nimport { trackSmartAccountsKitFunctionCall } from './analytics';\n\nconst signatureTypes = ['ECDSA'] as const;\n\nexport type SignatureType = (typeof signatureTypes)[number];\n\n/**\n * Represents a partial signature that can be aggregated with others.\n */\nexport type PartialSignature = {\n signer: Address;\n signature: Hex;\n type: SignatureType;\n};\n\n/**\n * Aggregates signatures into a single signature as expected by the MultiSig implementation.\n *\n * @param params - The parameters for signature aggregation.\n * @param params.signatures - The array of partial signatures to aggregate.\n * @returns The aggregated signature.\n */\nexport const aggregateSignature = ({\n signatures,\n}: {\n signatures: PartialSignature[];\n}): Hex => {\n trackSmartAccountsKitFunctionCall('aggregateSignature', {\n signatureCount: signatures.length,\n });\n\n if (signatures.length === 0) {\n return '0x';\n }\n\n for (const { type } of signatures) {\n if (!signatureTypes.includes(type)) {\n throw new Error(`Invalid signature type: ${type}`);\n }\n }\n\n // Sort signatures by signer address as required by MultiSig implementation\n const sortedSignatures = [...signatures].sort((a, b) =>\n a.signer.localeCompare(b.signer),\n );\n\n // Concatenate all signatures\n return concat(sortedSignatures.map(({ signature }) => signature));\n};\n\n/**\n * Type definition for the aggregateSignature function parameters.\n */\nexport type AggregateSignatureParams = {\n signatures: PartialSignature[];\n};\n","export { toMetaMaskSmartAccount } from './toMetaMaskSmartAccount';\n\nexport {\n createDelegation,\n createOpenDelegation,\n signDelegation,\n ROOT_AUTHORITY,\n ANY_BENEFICIARY,\n} from './delegation';\n\nexport type {\n CreateDelegationOptions,\n CreateOpenDelegationOptions,\n} from './delegation';\n\nexport type {\n SmartAccountsEnvironment,\n MultiSigDeleGatorDeployParams,\n HybridDeleGatorDeployParams,\n SignUserOperationParams,\n SignDelegationParams,\n MetaMaskSmartAccountImplementation,\n ToMetaMaskSmartAccountReturnType,\n MetaMaskSmartAccount,\n WalletSignerConfig,\n AccountSignerConfig,\n WebAuthnSignerConfig,\n HybridSignerConfig,\n MultiSigSignerConfig,\n Delegation,\n Caveat,\n PermissionContext,\n} from './types';\n\nexport {\n PREFERRED_VERSION,\n getSmartAccountsEnvironment,\n} from './smartAccountsEnvironment';\n\nexport {\n Implementation,\n TransferWindow,\n ScopeType,\n CaveatType,\n} from './constants';\n\nexport { createExecution, ExecutionMode } from './executions';\n\nexport type { ExecutionStruct, CreateExecutionArgs } from './executions';\n\nexport type { Caveats } from './caveatBuilder';\n\nexport { createCaveat } from './caveats';\n\nexport { BalanceChangeType } from '@metamask/delegation-core';\n\nexport { aggregateSignature } from './signatures';\n\nexport { type SignatureType, type PartialSignature } from './signatures';\n\nexport type { AggregateSignatureParams } from './signatures';\n\nexport { signUserOperation } from './userOp';\n\nexport * as contracts from './contracts';\n\nexport * as actions from './actions';\n\nexport {\n createCaveatEnforcerClient,\n type CaveatEnforcerClient,\n} from './actions/caveatEnforcerClient';\n\nexport {\n createInfuraBundlerClient,\n type InfuraBundlerClient,\n type GasPriceTier,\n type UserOperationGasPriceResponse,\n} from './actions/infuraBundlerClient';\n","import type { Client, Transport, Chain, Account } from 'viem';\n\nimport { trackSmartAccountsKitFunctionCall } from '../analytics';\nimport type { SmartAccountsEnvironment } from '../types';\nimport {\n caveatEnforcerActions,\n type CaveatEnforcerParams,\n type PeriodTransferResult,\n type StreamingResult,\n} from './getCaveatAvailableAmount';\n\n/**\n * Type for client extended with caveat enforcer actions.\n */\nexport type CaveatEnforcerClient<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends Account | undefined = Account | undefined,\n> = Client<TTransport, TChain, TAccount> &\n ReturnType<ReturnType<typeof caveatEnforcerActions>>;\n\n/**\n * Create a viem client extended with caveat enforcer actions.\n *\n * @param params - The parameters object.\n * @param params.client - The viem client.\n * @param params.environment - The SmartAccountsEnvironment.\n * @returns The extended client with caveat enforcer actions.\n */\nexport function createCaveatEnforcerClient<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends Account | undefined = Account | undefined,\n>({\n client,\n environment,\n}: {\n client: Client<TTransport, TChain, TAccount>;\n environment: SmartAccountsEnvironment;\n}): CaveatEnforcerClient<TTransport, TChain, TAccount> {\n trackSmartAccountsKitFunctionCall('createCaveatEnforcerClient', {\n chainId: client.chain?.id ?? null,\n });\n\n return client.extend(caveatEnforcerActions({ environment }));\n}\n\n// Re-export types for convenience\nexport type { CaveatEnforcerParams, PeriodTransferResult, StreamingResult };\n","import type { Transport, Chain, Hex, Client, Account } from 'viem';\nimport {\n createBundlerClient,\n type BundlerClient,\n type BundlerClientConfig,\n type SmartAccount,\n} from 'viem/account-abstraction';\n\nimport { trackSmartAccountsKitFunctionCall } from '../analytics';\n\n/**\n * Gas price tiers returned by pimlico_getUserOperationGasPrice\n */\nexport type GasPriceTier = {\n /** Maximum fee per gas in hex format */\n maxFeePerGas: Hex;\n /** Maximum priority fee per gas in hex format */\n maxPriorityFeePerGas: Hex;\n};\n\n/**\n * Response from pimlico_getUserOperationGasPrice RPC method\n */\nexport type UserOperationGasPriceResponse = {\n /** Slow gas price tier */\n slow: GasPriceTier;\n /** Standard gas price tier */\n standard: GasPriceTier;\n /** Fast gas price tier */\n fast: GasPriceTier;\n};\n\n/**\n * Pimlico bundler schema for type-safe RPC method calls\n */\n/* eslint-disable @typescript-eslint/naming-convention */\ntype PimlicoBundlerSchema = [\n {\n Method: 'pimlico_getUserOperationGasPrice';\n Parameters: [];\n ReturnType: UserOperationGasPriceResponse;\n },\n];\n\n/**\n * Infura bundler actions for extending bundler clients.\n *\n * @returns A function that takes a client and returns the client extension with Infura bundler actions.\n */\nconst infuraBundlerActions = () => (client: Client) => ({\n /**\n * Get user operation gas prices from Infura bundler.\n * Calls the pimlico_getUserOperationGasPrice RPC method.\n *\n * @returns Promise resolving to gas price tiers (slow, standard, fast).\n * @example\n * ```typescript\n * const gasPrices = await bundlerClient.getUserOperationGasPrice();\n * console.log(gasPrices.standard.maxFeePerGas);\n * ```\n */\n async getUserOperationGasPrice(): Promise<UserOperationGasPriceResponse> {\n const pimlicoClient = client as Client<\n Transport,\n Chain | undefined,\n Account | undefined,\n PimlicoBundlerSchema\n >;\n\n return await pimlicoClient.request({\n method: 'pimlico_getUserOperationGasPrice',\n params: [],\n });\n },\n});\n\n/**\n * Type for bundler client extended with Infura bundler actions.\n */\nexport type InfuraBundlerClient<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartAccount | undefined = SmartAccount | undefined,\n> = BundlerClient<TTransport, TChain, TAccount> & {\n /**\n * Get user operation gas prices from Infura bundler.\n * Calls the pimlico_getUserOperationGasPrice RPC method.\n *\n * @returns Promise resolving to gas price tiers (slow, standard, fast).\n */\n getUserOperationGasPrice(): Promise<UserOperationGasPriceResponse>;\n};\n\n/**\n * Creates an Infura bundler client extended with Infura bundler actions.\n *\n * This is a wrapper around viem's createBundlerClient that extends it with\n * the getUserOperationGasPrice method for retrieving gas prices from Pimlico's\n * bundler infrastructure via Infura's proxy.\n *\n * @param config - Configuration for the bundler client.\n * @returns Extended bundler client with Infura bundler actions.\n * @example\n * ```typescript\n * import { createPublicClient, http } from 'viem';\n * import { sepolia } from 'viem/chains';\n * import { createInfuraBundlerClient } from '@metamask/smart-accounts-kit';\n *\n * const publicClient = createPublicClient({\n * chain: sepolia,\n * transport: http('https://sepolia.infura.io/v3/YOUR_API_KEY'),\n * });\n *\n * const bundlerClient = createInfuraBundlerClient({\n * client: publicClient,\n * transport: http('https://sepolia.infura.io/v3/YOUR_API_KEY'),\n * chain: sepolia,\n * });\n *\n * // Use standard bundler methods\n * const userOpHash = await bundlerClient.sendUserOperation({...});\n *\n * // Use Infura specific methods\n * const gasPrices = await bundlerClient.getUserOperationGasPrice();\n * ```\n */\nexport function createInfuraBundlerClient<\n TTransport extends Transport,\n TChain extends Chain | undefined = undefined,\n TAccount extends SmartAccount | undefined = undefined,\n>(\n config: BundlerClientConfig<TTransport, TChain, TAccount>,\n): InfuraBundlerClient<TTransport, TChain, TAccount> {\n trackSmartAccountsKitFunctionCall('createInfuraBundlerClient', {\n chainId: config.chain?.id ?? null,\n });\n // Create the base bundler client using viem's function\n const baseBundlerClient = createBundlerClient(config);\n\n // Extend the client with Infura bundler actions\n return baseBundlerClient.extend(\n infuraBundlerActions(),\n ) as unknown as InfuraBundlerClient<TTransport, TChain, TAccount>;\n}\n"]}
|