@metamask/smart-accounts-kit 1.5.0 → 1.6.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 +47 -25
- package/dist/actions/index.cjs +5 -6
- package/dist/actions/index.cjs.map +1 -1
- package/dist/actions/index.d.cts +3 -3
- package/dist/actions/index.d.ts +3 -3
- package/dist/actions/index.mjs +4 -5
- package/dist/{caveats-DQ6HoAHe.d.ts → caveats-B2OssjV4.d.ts} +1 -2
- package/dist/{caveats-CaSt_VHs.d.cts → caveats-gqMBZKkI.d.cts} +1 -2
- package/dist/{chunk-SOFB2MXG.cjs → chunk-2OS36DVV.cjs} +8 -1
- package/dist/chunk-2OS36DVV.cjs.map +1 -0
- package/dist/{chunk-XEOE25DE.cjs → chunk-2ZOWIAP3.cjs} +98 -68
- package/dist/chunk-2ZOWIAP3.cjs.map +1 -0
- package/dist/{chunk-BGOSYTKV.mjs → chunk-AZYTTGON.mjs} +38 -8
- package/dist/chunk-AZYTTGON.mjs.map +1 -0
- package/dist/{chunk-SCS3CFRE.cjs → chunk-DCI2AN4N.cjs} +15 -17
- package/dist/chunk-DCI2AN4N.cjs.map +1 -0
- package/dist/{chunk-DN4O5VOP.cjs → chunk-EPU4O7FY.cjs} +158 -151
- package/dist/chunk-EPU4O7FY.cjs.map +1 -0
- package/dist/{chunk-QCULIK3O.mjs → chunk-GMGJRC3D.mjs} +8 -1
- package/dist/chunk-GMGJRC3D.mjs.map +1 -0
- package/dist/chunk-IMO6XNDJ.mjs +14 -0
- package/dist/chunk-IMO6XNDJ.mjs.map +1 -0
- package/dist/chunk-IQT6XFDT.cjs +14 -0
- package/dist/chunk-IQT6XFDT.cjs.map +1 -0
- package/dist/{chunk-FH6HZCHI.cjs → chunk-JKVSTPEC.cjs} +200 -18
- package/dist/chunk-JKVSTPEC.cjs.map +1 -0
- package/dist/{chunk-N66VAWMO.mjs → chunk-K7GTZGKJ.mjs} +2 -2
- package/dist/{chunk-TBHT26BV.mjs → chunk-L3EZCIY6.mjs} +67 -60
- package/dist/chunk-L3EZCIY6.mjs.map +1 -0
- package/dist/{chunk-7FYDQNJ3.cjs → chunk-PQPAEHJZ.cjs} +12 -12
- package/dist/{chunk-7FYDQNJ3.cjs.map → chunk-PQPAEHJZ.cjs.map} +1 -1
- package/dist/{chunk-MV2KHN75.mjs → chunk-TNGQTVSY.mjs} +163 -35
- package/dist/chunk-TNGQTVSY.mjs.map +1 -0
- package/dist/{chunk-YXHUT56Z.mjs → chunk-UJQ3JN3U.mjs} +4 -6
- package/dist/{chunk-YXHUT56Z.mjs.map → chunk-UJQ3JN3U.mjs.map} +1 -1
- package/dist/{chunk-IBZSNB7D.cjs → chunk-W6HPAK4M.cjs} +202 -74
- package/dist/chunk-W6HPAK4M.cjs.map +1 -0
- package/dist/{chunk-W7O2UQL5.mjs → chunk-YVU66KSH.mjs} +188 -6
- package/dist/chunk-YVU66KSH.mjs.map +1 -0
- package/dist/contracts/index.cjs +5 -6
- package/dist/contracts/index.cjs.map +1 -1
- package/dist/contracts/index.d.cts +4 -4
- package/dist/contracts/index.d.ts +4 -4
- package/dist/contracts/index.mjs +4 -5
- package/dist/{delegation-DbPGWKfP.d.ts → decodeRevertReason-CmmCpmZ_.d.cts} +11 -3
- package/dist/{delegation-BKkEyxZY.d.cts → decodeRevertReason-dOTpJx2h.d.ts} +11 -3
- package/dist/experimental/index.cjs +364 -9
- package/dist/experimental/index.cjs.map +1 -1
- package/dist/experimental/index.d.cts +39 -3
- package/dist/experimental/index.d.ts +39 -3
- package/dist/experimental/index.mjs +357 -2
- package/dist/experimental/index.mjs.map +1 -1
- package/dist/index-B1Cmezvh.d.cts +61 -0
- package/dist/{index-DXdlz7t4.d.ts → index-BkgdU4LI.d.ts} +99 -93
- package/dist/{index-G78z6nwi.d.ts → index-DUJmm8Wz.d.ts} +13 -5
- package/dist/{index-yU3olCJV.d.cts → index-Dv4jPzhe.d.cts} +99 -93
- package/dist/index-LqiEgBjV.d.ts +61 -0
- package/dist/{index-DfDAuvr5.d.cts → index-X7Qn3JTg.d.cts} +13 -5
- package/dist/index.cjs +22 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.mjs +9 -11
- package/dist/index.mjs.map +1 -1
- package/dist/{resolveCaveats-DiqGB-T5.d.cts → resolveCaveats-A9xC29l8.d.cts} +160 -62
- package/dist/{resolveCaveats-s2snaFEo.d.ts → resolveCaveats-A9xC29l8.d.ts} +160 -62
- package/dist/utils/index.cjs +13 -6
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +8 -5
- package/dist/utils/index.d.ts +8 -5
- package/dist/utils/index.mjs +16 -9
- package/package.json +7 -6
- package/dist/chunk-4QXIOE7F.mjs +0 -79
- package/dist/chunk-4QXIOE7F.mjs.map +0 -1
- package/dist/chunk-BGOSYTKV.mjs.map +0 -1
- package/dist/chunk-DN4O5VOP.cjs.map +0 -1
- package/dist/chunk-FH6HZCHI.cjs.map +0 -1
- package/dist/chunk-IBZSNB7D.cjs.map +0 -1
- package/dist/chunk-MOHCTPYQ.cjs +0 -79
- package/dist/chunk-MOHCTPYQ.cjs.map +0 -1
- package/dist/chunk-MV2KHN75.mjs.map +0 -1
- package/dist/chunk-QCULIK3O.mjs.map +0 -1
- package/dist/chunk-SCS3CFRE.cjs.map +0 -1
- package/dist/chunk-SOFB2MXG.cjs.map +0 -1
- package/dist/chunk-TBHT26BV.mjs.map +0 -1
- package/dist/chunk-W7O2UQL5.mjs.map +0 -1
- package/dist/chunk-XEOE25DE.cjs.map +0 -1
- package/dist/types-BWaH4KH1.d.cts +0 -155
- package/dist/types-BWaH4KH1.d.ts +0 -155
- /package/dist/{chunk-N66VAWMO.mjs.map → chunk-K7GTZGKJ.mjs.map} +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { j as ScopeType, B as Erc20PeriodTransferBuilderConfig, F as Erc20StreamingBuilderConfig, G as Erc20TransferAmountBuilderConfig, J as Erc721TransferBuilderConfig, K as AllowedCalldataBuilderConfig, L as ExactCalldataBuilderConfig, V as ValueLteBuilderConfig, N as AllowedTargetsBuilderConfig, O as AllowedMethodsBuilderConfig, Q as NativeTokenPeriodTransferBuilderConfig, R as NativeTokenStreamingBuilderConfig, U as NativeTokenTransferAmountBuilderConfig, X as OwnershipTransferBuilderConfig } from './resolveCaveats-A9xC29l8.js';
|
|
2
|
+
|
|
3
|
+
type Erc20PeriodicScopeConfig = {
|
|
4
|
+
type: ScopeType.Erc20PeriodTransfer;
|
|
5
|
+
} & Erc20PeriodTransferBuilderConfig;
|
|
6
|
+
|
|
7
|
+
type Erc20StreamingScopeConfig = {
|
|
8
|
+
type: ScopeType.Erc20Streaming;
|
|
9
|
+
} & Erc20StreamingBuilderConfig;
|
|
10
|
+
|
|
11
|
+
type Erc20TransferScopeConfig = {
|
|
12
|
+
type: ScopeType.Erc20TransferAmount;
|
|
13
|
+
} & Erc20TransferAmountBuilderConfig;
|
|
14
|
+
|
|
15
|
+
type Erc721ScopeBaseConfig = {
|
|
16
|
+
type: ScopeType.Erc721Transfer;
|
|
17
|
+
};
|
|
18
|
+
type Erc721ScopeConfig = Erc721ScopeBaseConfig & Erc721TransferBuilderConfig;
|
|
19
|
+
|
|
20
|
+
type FunctionCallScopeBaseConfig = {
|
|
21
|
+
type: ScopeType.FunctionCall;
|
|
22
|
+
allowedCalldata?: AllowedCalldataBuilderConfig[];
|
|
23
|
+
exactCalldata?: ExactCalldataBuilderConfig;
|
|
24
|
+
valueLte?: ValueLteBuilderConfig;
|
|
25
|
+
};
|
|
26
|
+
type FunctionCallScopeConfig = FunctionCallScopeBaseConfig & AllowedTargetsBuilderConfig & AllowedMethodsBuilderConfig;
|
|
27
|
+
|
|
28
|
+
type NativeTokenPeriodicScopeConfig = {
|
|
29
|
+
type: ScopeType.NativeTokenPeriodTransfer;
|
|
30
|
+
allowedCalldata?: AllowedCalldataBuilderConfig[];
|
|
31
|
+
exactCalldata?: ExactCalldataBuilderConfig;
|
|
32
|
+
} & NativeTokenPeriodTransferBuilderConfig;
|
|
33
|
+
|
|
34
|
+
type NativeTokenStreamingScopeConfig = {
|
|
35
|
+
type: ScopeType.NativeTokenStreaming;
|
|
36
|
+
allowedCalldata?: AllowedCalldataBuilderConfig[];
|
|
37
|
+
exactCalldata?: ExactCalldataBuilderConfig;
|
|
38
|
+
} & NativeTokenStreamingBuilderConfig;
|
|
39
|
+
|
|
40
|
+
type NativeTokenTransferScopeConfig = {
|
|
41
|
+
type: ScopeType.NativeTokenTransferAmount;
|
|
42
|
+
allowedCalldata?: AllowedCalldataBuilderConfig[];
|
|
43
|
+
exactCalldata?: ExactCalldataBuilderConfig;
|
|
44
|
+
} & NativeTokenTransferAmountBuilderConfig;
|
|
45
|
+
|
|
46
|
+
type OwnershipScopeBaseConfig = {
|
|
47
|
+
type: ScopeType.OwnershipTransfer;
|
|
48
|
+
};
|
|
49
|
+
type OwnershipScopeConfig = OwnershipScopeBaseConfig & OwnershipTransferBuilderConfig;
|
|
50
|
+
|
|
51
|
+
type ConvertScopeConfigsToInputs<T extends {
|
|
52
|
+
type: ScopeType;
|
|
53
|
+
}> = T extends {
|
|
54
|
+
type: ScopeType;
|
|
55
|
+
} ? Omit<T, 'type'> & {
|
|
56
|
+
type: T['type'] | `${T['type']}`;
|
|
57
|
+
} : never;
|
|
58
|
+
type ScopeConfigBase = Erc20TransferScopeConfig | Erc20StreamingScopeConfig | Erc20PeriodicScopeConfig | NativeTokenTransferScopeConfig | NativeTokenStreamingScopeConfig | NativeTokenPeriodicScopeConfig | Erc721ScopeConfig | OwnershipScopeConfig | FunctionCallScopeConfig;
|
|
59
|
+
type ScopeConfig = ConvertScopeConfigsToInputs<ScopeConfigBase>;
|
|
60
|
+
|
|
61
|
+
export type { ScopeConfig as S };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
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,
|
|
3
|
-
import { S as ScopeConfig
|
|
2
|
+
import { S as SmartAccountsEnvironment, P as PermissionContext, c as Caveats, D as Delegation, p as Call } from './resolveCaveats-A9xC29l8.cjs';
|
|
3
|
+
import { S as ScopeConfig } from './index-B1Cmezvh.cjs';
|
|
4
4
|
import { Rule, PermissionRequest as PermissionRequest$1, PermissionTypes as PermissionTypes$1, PermissionResponse as PermissionResponse$1 } from '@metamask/7715-permission-types';
|
|
5
|
+
import { ApprovalRevocationTerms } from '@metamask/delegation-core';
|
|
5
6
|
import { SmartAccount, SendUserOperationParameters } from 'viem/account-abstraction';
|
|
6
7
|
import { U as UserOperationV07 } from './userOp-DKgjzz7B.cjs';
|
|
7
8
|
|
|
@@ -96,7 +97,13 @@ type Erc20TokenRevocationPermission = BasePermission & {
|
|
|
96
97
|
justification?: string;
|
|
97
98
|
};
|
|
98
99
|
};
|
|
99
|
-
type
|
|
100
|
+
type TokenApprovalRevocationPermission = BasePermission & {
|
|
101
|
+
type: 'token-approval-revocation';
|
|
102
|
+
data: ApprovalRevocationTerms & {
|
|
103
|
+
justification?: string;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
type PermissionTypes = NativeTokenStreamPermission | NativeTokenPeriodicPermission | NativeTokenAllowancePermission | Erc20TokenStreamPermission | Erc20TokenPeriodicPermission | Erc20TokenAllowancePermission | Erc20TokenRevocationPermission | TokenApprovalRevocationPermission;
|
|
100
107
|
type PermissionRequestParameter = {
|
|
101
108
|
chainId: number;
|
|
102
109
|
permission: PermissionTypes;
|
|
@@ -303,6 +310,7 @@ type index_SignUserOperationParameters = SignUserOperationParameters;
|
|
|
303
310
|
type index_SignUserOperationReturnType = SignUserOperationReturnType;
|
|
304
311
|
type index_StreamingResult = StreamingResult;
|
|
305
312
|
type index_SupportedPermissionInfo = SupportedPermissionInfo;
|
|
313
|
+
type index_TokenApprovalRevocationPermission = TokenApprovalRevocationPermission;
|
|
306
314
|
declare const index_caveatEnforcerActions: typeof caveatEnforcerActions;
|
|
307
315
|
declare const index_erc7710BundlerActions: typeof erc7710BundlerActions;
|
|
308
316
|
declare const index_erc7710WalletActions: typeof erc7710WalletActions;
|
|
@@ -320,7 +328,7 @@ declare const index_signDelegationActions: typeof signDelegationActions;
|
|
|
320
328
|
declare const index_signUserOperation: typeof signUserOperation;
|
|
321
329
|
declare const index_signUserOperationActions: typeof signUserOperationActions;
|
|
322
330
|
declare namespace index {
|
|
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 };
|
|
331
|
+
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, type index_TokenApprovalRevocationPermission as TokenApprovalRevocationPermission, 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 };
|
|
324
332
|
}
|
|
325
333
|
|
|
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,
|
|
334
|
+
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, type TokenApprovalRevocationPermission as T, redelegatePermissionContextAction as U, redelegatePermissionContextOpenAction as V, erc7715RequestExecutionPermissionsAction as W, signDelegation as X, signDelegationActions as Y, signUserOperation as Z, signUserOperationActions as _, 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 };
|
package/dist/index.cjs
CHANGED
|
@@ -2,28 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunk2ZOWIAP3cjs = require('./chunk-2ZOWIAP3.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
require('./chunk-
|
|
8
|
+
var _chunkEPU4O7FYcjs = require('./chunk-EPU4O7FY.cjs');
|
|
9
|
+
require('./chunk-PQPAEHJZ.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkDCI2AN4Ncjs = require('./chunk-DCI2AN4N.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
var
|
|
22
|
-
require('./chunk-
|
|
21
|
+
var _chunk2OS36DVVcjs = require('./chunk-2OS36DVV.cjs');
|
|
22
|
+
require('./chunk-JKVSTPEC.cjs');
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
var _chunkMOHCTPYQcjs = require('./chunk-MOHCTPYQ.cjs');
|
|
27
26
|
|
|
28
27
|
|
|
29
28
|
|
|
@@ -37,8 +36,7 @@ var _chunkMOHCTPYQcjs = require('./chunk-MOHCTPYQ.cjs');
|
|
|
37
36
|
|
|
38
37
|
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
var _chunkIBZSNB7Dcjs = require('./chunk-IBZSNB7D.cjs');
|
|
39
|
+
var _chunkW6HPAK4Mcjs = require('./chunk-W6HPAK4M.cjs');
|
|
42
40
|
|
|
43
41
|
// src/toMetaMaskSmartAccount.ts
|
|
44
42
|
|
|
@@ -61,7 +59,7 @@ var signatureTypes = ["ECDSA"];
|
|
|
61
59
|
var aggregateSignature = ({
|
|
62
60
|
signatures
|
|
63
61
|
}) => {
|
|
64
|
-
|
|
62
|
+
_chunkW6HPAK4Mcjs.trackSmartAccountsKitFunctionCall.call(void 0, "aggregateSignature", {
|
|
65
63
|
signatureCount: signatures.length
|
|
66
64
|
});
|
|
67
65
|
if (signatures.length === 0) {
|
|
@@ -117,7 +115,7 @@ var resolveHybridSigner = (config) => {
|
|
|
117
115
|
if (webAuthnAccount.type !== "webAuthn") {
|
|
118
116
|
throw new Error("Account is not a webAuthn account");
|
|
119
117
|
}
|
|
120
|
-
const encodeSignature = (result) =>
|
|
118
|
+
const encodeSignature = (result) => _chunkDCI2AN4Ncjs.encodeDeleGatorSignature.call(void 0,
|
|
121
119
|
keyId,
|
|
122
120
|
result.signature,
|
|
123
121
|
result.webauthn.clientDataJSON,
|
|
@@ -125,7 +123,7 @@ var resolveHybridSigner = (config) => {
|
|
|
125
123
|
);
|
|
126
124
|
const signMessage = async (args) => webAuthnAccount.signMessage(args).then(encodeSignature);
|
|
127
125
|
const signTypedData = async (typedDataDefinition) => webAuthnAccount.signTypedData(typedDataDefinition).then(encodeSignature);
|
|
128
|
-
const getStubSignature = async () =>
|
|
126
|
+
const getStubSignature = async () => _chunkDCI2AN4Ncjs.createDummyWebAuthnSignature.call(void 0, keyId);
|
|
129
127
|
return {
|
|
130
128
|
signMessage,
|
|
131
129
|
signTypedData,
|
|
@@ -236,7 +234,7 @@ async function toMetaMaskSmartAccount(params) {
|
|
|
236
234
|
implementation,
|
|
237
235
|
nonceKeyManager
|
|
238
236
|
} = params;
|
|
239
|
-
|
|
237
|
+
_chunkW6HPAK4Mcjs.trackSmartAccountsKitFunctionCall.call(void 0, "toMetaMaskSmartAccount", {
|
|
240
238
|
implementation,
|
|
241
239
|
hasAddress: params.address !== void 0,
|
|
242
240
|
hasEnvironment: params.environment !== void 0,
|
|
@@ -249,7 +247,7 @@ async function toMetaMaskSmartAccount(params) {
|
|
|
249
247
|
implementation,
|
|
250
248
|
signer: params.signer
|
|
251
249
|
});
|
|
252
|
-
const environment = _nullishCoalesce(params.environment, () => (
|
|
250
|
+
const environment = _nullishCoalesce(params.environment, () => ( _chunk2OS36DVVcjs.getSmartAccountsEnvironment.call(void 0, chain.id)));
|
|
253
251
|
let address, factoryData;
|
|
254
252
|
if (params.address) {
|
|
255
253
|
factoryData = void 0;
|
|
@@ -258,7 +256,7 @@ async function toMetaMaskSmartAccount(params) {
|
|
|
258
256
|
if (implementation === "Stateless7702" /* Stateless7702 */) {
|
|
259
257
|
throw new Error("Stateless7702 does not support counterfactual accounts");
|
|
260
258
|
}
|
|
261
|
-
const accountData = await
|
|
259
|
+
const accountData = await _chunkDCI2AN4Ncjs.getCounterfactualAccountData.call(void 0, {
|
|
262
260
|
factory: environment.SimpleFactory,
|
|
263
261
|
implementations: environment.implementations,
|
|
264
262
|
implementation,
|
|
@@ -305,7 +303,7 @@ async function toMetaMaskSmartAccount(params) {
|
|
|
305
303
|
);
|
|
306
304
|
}
|
|
307
305
|
const { delegation, chainId } = delegationParams;
|
|
308
|
-
const delegationStruct =
|
|
306
|
+
const delegationStruct = _chunkW6HPAK4Mcjs.toDelegationStruct.call(void 0, {
|
|
309
307
|
...delegation,
|
|
310
308
|
signature: "0x"
|
|
311
309
|
});
|
|
@@ -316,7 +314,7 @@ async function toMetaMaskSmartAccount(params) {
|
|
|
316
314
|
version: "1",
|
|
317
315
|
verifyingContract: environment.DelegationManager
|
|
318
316
|
},
|
|
319
|
-
types:
|
|
317
|
+
types: _chunkW6HPAK4Mcjs.SIGNABLE_DELEGATION_TYPED_DATA,
|
|
320
318
|
primaryType: "Delegation",
|
|
321
319
|
message: delegationStruct
|
|
322
320
|
});
|
|
@@ -341,14 +339,14 @@ async function toMetaMaskSmartAccount(params) {
|
|
|
341
339
|
version: "1",
|
|
342
340
|
verifyingContract: address
|
|
343
341
|
},
|
|
344
|
-
types:
|
|
342
|
+
types: _chunk2OS36DVVcjs.SIGNABLE_USER_OP_TYPED_DATA,
|
|
345
343
|
primaryType: "PackedUserOperation",
|
|
346
344
|
message: { ...packedUserOp, entryPoint: entryPoint.address }
|
|
347
345
|
});
|
|
348
346
|
return signature;
|
|
349
347
|
};
|
|
350
348
|
const getAddress = async () => address;
|
|
351
|
-
const encodeCalls = async (calls) =>
|
|
349
|
+
const encodeCalls = async (calls) => _chunkDCI2AN4Ncjs.encodeCallsForCaller.call(void 0, address, calls);
|
|
352
350
|
const signerMethods = _nullishCoalesce(signer, () => ( {
|
|
353
351
|
signMessage: async () => {
|
|
354
352
|
throw new Error(
|
|
@@ -382,7 +380,7 @@ async function toMetaMaskSmartAccount(params) {
|
|
|
382
380
|
if (implementation === "Stateless7702" /* Stateless7702 */) {
|
|
383
381
|
return {
|
|
384
382
|
...smartAccount,
|
|
385
|
-
isDeployed: async () =>
|
|
383
|
+
isDeployed: async () => _chunk2ZOWIAP3cjs.isValid7702Implementation.call(void 0, {
|
|
386
384
|
client,
|
|
387
385
|
accountAddress: address,
|
|
388
386
|
environment
|
|
@@ -400,10 +398,10 @@ function createCaveatEnforcerClient({
|
|
|
400
398
|
client,
|
|
401
399
|
environment
|
|
402
400
|
}) {
|
|
403
|
-
|
|
401
|
+
_chunkW6HPAK4Mcjs.trackSmartAccountsKitFunctionCall.call(void 0, "createCaveatEnforcerClient", {
|
|
404
402
|
chainId: _nullishCoalesce(_optionalChain([client, 'access', _2 => _2.chain, 'optionalAccess', _3 => _3.id]), () => ( null))
|
|
405
403
|
});
|
|
406
|
-
return client.extend(
|
|
404
|
+
return client.extend(_chunk2ZOWIAP3cjs.caveatEnforcerActions.call(void 0, { environment }));
|
|
407
405
|
}
|
|
408
406
|
|
|
409
407
|
// src/actions/infuraBundlerClient.ts
|
|
@@ -431,7 +429,7 @@ var infuraBundlerActions = () => (client) => ({
|
|
|
431
429
|
}
|
|
432
430
|
});
|
|
433
431
|
function createInfuraBundlerClient(config) {
|
|
434
|
-
|
|
432
|
+
_chunkW6HPAK4Mcjs.trackSmartAccountsKitFunctionCall.call(void 0, "createInfuraBundlerClient", {
|
|
435
433
|
chainId: _nullishCoalesce(_optionalChain([config, 'access', _4 => _4.chain, 'optionalAccess', _5 => _5.id]), () => ( null))
|
|
436
434
|
});
|
|
437
435
|
const baseBundlerClient = _accountabstraction.createBundlerClient.call(void 0, config);
|
|
@@ -462,5 +460,5 @@ function createInfuraBundlerClient(config) {
|
|
|
462
460
|
|
|
463
461
|
|
|
464
462
|
|
|
465
|
-
exports.ANY_BENEFICIARY =
|
|
463
|
+
exports.ANY_BENEFICIARY = _chunkW6HPAK4Mcjs.ANY_BENEFICIARY; exports.BalanceChangeType = _delegationcore.BalanceChangeType; exports.CaveatType = _chunkW6HPAK4Mcjs.CaveatType; exports.ExecutionMode = _chunkW6HPAK4Mcjs.ExecutionMode; exports.Implementation = _chunkW6HPAK4Mcjs.Implementation; exports.PREFERRED_VERSION = _chunk2OS36DVVcjs.PREFERRED_VERSION; exports.ROOT_AUTHORITY = _chunkW6HPAK4Mcjs.ROOT_AUTHORITY; exports.ScopeType = _chunkW6HPAK4Mcjs.ScopeType; exports.TransferWindow = _chunkW6HPAK4Mcjs.TransferWindow; exports.actions = _chunk2ZOWIAP3cjs.actions_exports; exports.aggregateSignature = aggregateSignature; exports.contracts = _chunkEPU4O7FYcjs.contracts_exports; exports.createCaveat = _chunkW6HPAK4Mcjs.createCaveat; exports.createCaveatEnforcerClient = createCaveatEnforcerClient; exports.createDelegation = _chunkW6HPAK4Mcjs.createDelegation; exports.createExecution = _chunkW6HPAK4Mcjs.createExecution; exports.createInfuraBundlerClient = createInfuraBundlerClient; exports.createOpenDelegation = _chunkW6HPAK4Mcjs.createOpenDelegation; exports.getSmartAccountsEnvironment = _chunk2OS36DVVcjs.getSmartAccountsEnvironment; exports.signDelegation = _chunkW6HPAK4Mcjs.signDelegation; exports.signUserOperation = _chunk2OS36DVVcjs.signUserOperation; exports.toMetaMaskSmartAccount = toMetaMaskSmartAccount;
|
|
466
464
|
//# 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/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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;AACQ,MAAA;AACZ,IAAA;AAE4C,IAAA;AACnC,MAAA;AACoB,QAAA;AACpB,QAAA;AACG,QAAA;AACU,QAAA;AACrB,MAAA;AACO,MAAA;AACM,MAAA;AAC2B,MAAA;AACzC,IAAA;AAEM,IAAA;AACT,EAAA;AAE+B,EAAA;AAG7B,EAAA;AAE8B,EAAA;AACL,IAAA;AACb,MAAA;AACR,QAAA;AACF,MAAA;AACF,IAAA;AAC2B,IAAA;AACf,MAAA;AACR,QAAA;AACF,MAAA;AACF,IAAA;AAC8B,IAAA;AAClB,MAAA;AACR,QAAA;AACF,MAAA;AACF,IAAA;AACF,EAAA;AAE0C,EAAA;AACxC,IAAA;AACA,IAAA;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;ADmJsD;AACA;AIpVpB;AJsVoB;AACA;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"]}
|
|
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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACxCA;AACE;AACA;AACA;AAAA,2DACK;AAEP;AACE;AACA;AACA;AAAA,8DACK;ADyCP;AACA;AEpDA,4BAAuB;AFsDvB;AACA;AGtDA;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,IAA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A;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;ADiJsD;AACA;AIlVpB;AJoVoB;AACA;AK1WpD;AACA,EAAA;AACA,EAAA;AAIqD;AACnB,EAAA;AACH,IAAA;AAC9B,EAAA;AAE4C,EAAA;AAC/C;ALwWsD;AACA;AMrZtD;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;ANwSsD;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"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { I as Implementation, T as ToMetaMaskSmartAccountParameters, a as ToMetaMaskSmartAccountReturnType, S as SmartAccountsEnvironment } from './
|
|
2
|
-
export { A as AccountSignerConfig, C as Caveat, b as CaveatType, D as Delegation, H as HybridDeleGatorDeployParams,
|
|
3
|
-
export { C as CreateDelegationOptions, a as CreateOpenDelegationOptions, c as createDelegation, b as createOpenDelegation, s as signDelegation } from './
|
|
4
|
-
export { P as PREFERRED_VERSION, c as createCaveat, g as getSmartAccountsEnvironment } from './caveats-
|
|
5
|
-
export { C as Caveats, a as CreateExecutionArgs, E as ExecutionMode, b as ExecutionStruct, c as createExecution } from './resolveCaveats-DiqGB-T5.cjs';
|
|
1
|
+
import { I as Implementation, T as ToMetaMaskSmartAccountParameters, a as ToMetaMaskSmartAccountReturnType, S as SmartAccountsEnvironment } from './resolveCaveats-A9xC29l8.cjs';
|
|
2
|
+
export { A as AccountSignerConfig, C as Caveat, b as CaveatType, c as Caveats, d as CreateExecutionArgs, D as Delegation, E as ExecutionMode, e as ExecutionStruct, H as HybridDeleGatorDeployParams, f as HybridSignerConfig, M as MetaMaskSmartAccount, g as MetaMaskSmartAccountImplementation, h as MultiSigDeleGatorDeployParams, i as MultiSigSignerConfig, P as PermissionContext, j as ScopeType, k as SignDelegationParams, l as SignUserOperationParams, m as TransferWindow, W as WalletSignerConfig, n as WebAuthnSignerConfig, o as createExecution } from './resolveCaveats-A9xC29l8.cjs';
|
|
3
|
+
export { C as CreateDelegationOptions, a as CreateOpenDelegationOptions, c as createDelegation, b as createOpenDelegation, s as signDelegation } from './decodeRevertReason-CmmCpmZ_.cjs';
|
|
4
|
+
export { P as PREFERRED_VERSION, c as createCaveat, g as getSmartAccountsEnvironment } from './caveats-gqMBZKkI.cjs';
|
|
6
5
|
export { ANY_BENEFICIARY, BalanceChangeType, ROOT_AUTHORITY } from '@metamask/delegation-core';
|
|
7
6
|
import { Address, Hex, Transport, Chain, Account, Client } from 'viem';
|
|
8
7
|
export { s as signUserOperation } from './userOp-DKgjzz7B.cjs';
|
|
9
|
-
export { i as contracts } from './index-
|
|
10
|
-
import { c as caveatEnforcerActions } from './index-
|
|
11
|
-
export { i as actions } from './index-
|
|
8
|
+
export { i as contracts } from './index-Dv4jPzhe.cjs';
|
|
9
|
+
import { c as caveatEnforcerActions } from './index-X7Qn3JTg.cjs';
|
|
10
|
+
export { i as actions } from './index-X7Qn3JTg.cjs';
|
|
12
11
|
import { SmartAccount, BundlerClient, BundlerClientConfig } from 'viem/account-abstraction';
|
|
13
12
|
import '@metamask/delegation-abis';
|
|
14
13
|
import 'viem/chains';
|
|
14
|
+
import './index-B1Cmezvh.cjs';
|
|
15
15
|
import '@metamask/7715-permission-types';
|
|
16
16
|
|
|
17
17
|
declare function toMetaMaskSmartAccount<TImplementation extends Implementation>(params: ToMetaMaskSmartAccountParameters<TImplementation>): Promise<ToMetaMaskSmartAccountReturnType<TImplementation>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { I as Implementation, T as ToMetaMaskSmartAccountParameters, a as ToMetaMaskSmartAccountReturnType, S as SmartAccountsEnvironment } from './
|
|
2
|
-
export { A as AccountSignerConfig, C as Caveat, b as CaveatType, D as Delegation, H as HybridDeleGatorDeployParams,
|
|
3
|
-
export { C as CreateDelegationOptions, a as CreateOpenDelegationOptions, c as createDelegation, b as createOpenDelegation, s as signDelegation } from './
|
|
4
|
-
export { P as PREFERRED_VERSION, c as createCaveat, g as getSmartAccountsEnvironment } from './caveats-
|
|
5
|
-
export { C as Caveats, a as CreateExecutionArgs, E as ExecutionMode, b as ExecutionStruct, c as createExecution } from './resolveCaveats-s2snaFEo.js';
|
|
1
|
+
import { I as Implementation, T as ToMetaMaskSmartAccountParameters, a as ToMetaMaskSmartAccountReturnType, S as SmartAccountsEnvironment } from './resolveCaveats-A9xC29l8.js';
|
|
2
|
+
export { A as AccountSignerConfig, C as Caveat, b as CaveatType, c as Caveats, d as CreateExecutionArgs, D as Delegation, E as ExecutionMode, e as ExecutionStruct, H as HybridDeleGatorDeployParams, f as HybridSignerConfig, M as MetaMaskSmartAccount, g as MetaMaskSmartAccountImplementation, h as MultiSigDeleGatorDeployParams, i as MultiSigSignerConfig, P as PermissionContext, j as ScopeType, k as SignDelegationParams, l as SignUserOperationParams, m as TransferWindow, W as WalletSignerConfig, n as WebAuthnSignerConfig, o as createExecution } from './resolveCaveats-A9xC29l8.js';
|
|
3
|
+
export { C as CreateDelegationOptions, a as CreateOpenDelegationOptions, c as createDelegation, b as createOpenDelegation, s as signDelegation } from './decodeRevertReason-dOTpJx2h.js';
|
|
4
|
+
export { P as PREFERRED_VERSION, c as createCaveat, g as getSmartAccountsEnvironment } from './caveats-B2OssjV4.js';
|
|
6
5
|
export { ANY_BENEFICIARY, BalanceChangeType, ROOT_AUTHORITY } from '@metamask/delegation-core';
|
|
7
6
|
import { Address, Hex, Transport, Chain, Account, Client } from 'viem';
|
|
8
7
|
export { s as signUserOperation } from './userOp-DKgjzz7B.js';
|
|
9
|
-
export { i as contracts } from './index-
|
|
10
|
-
import { c as caveatEnforcerActions } from './index-
|
|
11
|
-
export { i as actions } from './index-
|
|
8
|
+
export { i as contracts } from './index-BkgdU4LI.js';
|
|
9
|
+
import { c as caveatEnforcerActions } from './index-DUJmm8Wz.js';
|
|
10
|
+
export { i as actions } from './index-DUJmm8Wz.js';
|
|
12
11
|
import { SmartAccount, BundlerClient, BundlerClientConfig } from 'viem/account-abstraction';
|
|
13
12
|
import '@metamask/delegation-abis';
|
|
14
13
|
import 'viem/chains';
|
|
14
|
+
import './index-LqiEgBjV.js';
|
|
15
15
|
import '@metamask/7715-permission-types';
|
|
16
16
|
|
|
17
17
|
declare function toMetaMaskSmartAccount<TImplementation extends Implementation>(params: ToMetaMaskSmartAccountParameters<TImplementation>): Promise<ToMetaMaskSmartAccountReturnType<TImplementation>>;
|
package/dist/index.mjs
CHANGED
|
@@ -2,31 +2,28 @@ import {
|
|
|
2
2
|
actions_exports,
|
|
3
3
|
caveatEnforcerActions,
|
|
4
4
|
isValid7702Implementation
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-AZYTTGON.mjs";
|
|
6
6
|
import {
|
|
7
7
|
contracts_exports
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-L3EZCIY6.mjs";
|
|
9
|
+
import "./chunk-K7GTZGKJ.mjs";
|
|
10
10
|
import {
|
|
11
11
|
createDummyWebAuthnSignature,
|
|
12
12
|
encodeCallsForCaller,
|
|
13
13
|
encodeDeleGatorSignature,
|
|
14
14
|
getCounterfactualAccountData
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-UJQ3JN3U.mjs";
|
|
16
16
|
import {
|
|
17
17
|
PREFERRED_VERSION,
|
|
18
18
|
SIGNABLE_USER_OP_TYPED_DATA,
|
|
19
19
|
getSmartAccountsEnvironment,
|
|
20
20
|
signUserOperation
|
|
21
|
-
} from "./chunk-
|
|
22
|
-
import "./chunk-
|
|
23
|
-
import {
|
|
24
|
-
ExecutionMode,
|
|
25
|
-
createExecution
|
|
26
|
-
} from "./chunk-4QXIOE7F.mjs";
|
|
21
|
+
} from "./chunk-GMGJRC3D.mjs";
|
|
22
|
+
import "./chunk-YVU66KSH.mjs";
|
|
27
23
|
import {
|
|
28
24
|
ANY_BENEFICIARY,
|
|
29
25
|
CaveatType,
|
|
26
|
+
ExecutionMode,
|
|
30
27
|
Implementation,
|
|
31
28
|
ROOT_AUTHORITY,
|
|
32
29
|
SIGNABLE_DELEGATION_TYPED_DATA,
|
|
@@ -34,11 +31,12 @@ import {
|
|
|
34
31
|
TransferWindow,
|
|
35
32
|
createCaveat,
|
|
36
33
|
createDelegation,
|
|
34
|
+
createExecution,
|
|
37
35
|
createOpenDelegation,
|
|
38
36
|
signDelegation,
|
|
39
37
|
toDelegationStruct,
|
|
40
38
|
trackSmartAccountsKitFunctionCall
|
|
41
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-TNGQTVSY.mjs";
|
|
42
40
|
|
|
43
41
|
// src/toMetaMaskSmartAccount.ts
|
|
44
42
|
import {
|