@metamask/smart-accounts-kit 0.4.0-beta.2 → 1.1.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/dist/actions/index.d.cts +2 -2
  3. package/dist/actions/index.d.ts +2 -2
  4. package/dist/{chunk-WPVSFOQM.mjs → chunk-45GHWVQA.mjs} +8 -9
  5. package/dist/chunk-45GHWVQA.mjs.map +1 -0
  6. package/dist/{chunk-DLD377CN.cjs → chunk-BYWRJGSK.cjs} +8 -9
  7. package/dist/chunk-BYWRJGSK.cjs.map +1 -0
  8. package/dist/{chunk-XN36L4RX.cjs → chunk-F2RG26RH.cjs} +2 -3
  9. package/dist/chunk-F2RG26RH.cjs.map +1 -0
  10. package/dist/{chunk-33AMUJBJ.mjs → chunk-YSBBRLMT.mjs} +1 -2
  11. package/dist/contracts/index.cjs +2 -2
  12. package/dist/contracts/index.d.cts +3 -3
  13. package/dist/contracts/index.d.ts +3 -3
  14. package/dist/contracts/index.mjs +1 -1
  15. package/dist/{delegation-D_TY-tAq.d.cts → delegation-Ci3me5Rg.d.cts} +2 -2
  16. package/dist/{delegation-DGUfyX-C.d.ts → delegation-DgmIOh21.d.ts} +2 -2
  17. package/dist/experimental/index.d.cts +1 -1
  18. package/dist/experimental/index.d.ts +1 -1
  19. package/dist/{index-B9bsjGqI.d.ts → index-CSjEW7MJ.d.cts} +3 -3
  20. package/dist/{index-FpCh2419.d.ts → index-D7fBuNV-.d.ts} +3 -3
  21. package/dist/{index-DvcKJcXi.d.cts → index-UF6eCzBC.d.ts} +3 -3
  22. package/dist/{index-CZes99jV.d.cts → index-Uj_xXVko.d.cts} +3 -3
  23. package/dist/index.cjs +50 -28
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +8 -8
  26. package/dist/index.d.ts +8 -8
  27. package/dist/index.mjs +47 -25
  28. package/dist/index.mjs.map +1 -1
  29. package/dist/{smartAccountsEnvironment-BU8kjlEv.d.cts → smartAccountsEnvironment-BIcho7e0.d.cts} +1 -1
  30. package/dist/{smartAccountsEnvironment-egxuflDO.d.ts → smartAccountsEnvironment-Bso0CIWt.d.ts} +1 -1
  31. package/dist/{types-BLYWtcR3.d.cts → types-BWaH4KH1.d.cts} +4 -3
  32. package/dist/{types-BLYWtcR3.d.ts → types-BWaH4KH1.d.ts} +4 -3
  33. package/dist/utils/index.cjs +2 -2
  34. package/dist/utils/index.d.cts +3 -3
  35. package/dist/utils/index.d.ts +3 -3
  36. package/dist/utils/index.mjs +1 -1
  37. package/package.json +5 -5
  38. package/dist/chunk-DLD377CN.cjs.map +0 -1
  39. package/dist/chunk-WPVSFOQM.mjs.map +0 -1
  40. package/dist/chunk-XN36L4RX.cjs.map +0 -1
  41. /package/dist/{chunk-33AMUJBJ.mjs.map → chunk-YSBBRLMT.mjs.map} +0 -0
@@ -1,5 +1,5 @@
1
1
  import { Hex } from 'viem';
2
- import { D as Delegation } from '../types-BLYWtcR3.cjs';
2
+ import { D as Delegation } from '../types-BWaH4KH1.cjs';
3
3
  import '@metamask/delegation-abis';
4
4
  import 'viem/account-abstraction';
5
5
  import 'viem/chains';
@@ -1,5 +1,5 @@
1
1
  import { Hex } from 'viem';
2
- import { D as Delegation } from '../types-BLYWtcR3.js';
2
+ import { D as Delegation } from '../types-BWaH4KH1.js';
3
3
  import '@metamask/delegation-abis';
4
4
  import 'viem/account-abstraction';
5
5
  import 'viem/chains';
@@ -1,8 +1,8 @@
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 { p as DelegationStruct, E as ExecutionMode, e as ExecutionStruct } from './delegation-DGUfyX-C.js';
5
- import { D as Delegation, P as PermissionContext } from './types-BLYWtcR3.js';
4
+ import { m as DelegationStruct, E as ExecutionMode, d as ExecutionStruct } from './delegation-Ci3me5Rg.cjs';
5
+ import { D as Delegation, P as PermissionContext } from './types-BWaH4KH1.cjs';
6
6
 
7
7
  declare const NAME$1 = "DelegationManager";
8
8
  declare const VERSION$1 = "1.3.0";
@@ -22134,4 +22134,4 @@ declare namespace index {
22134
22134
  export { index$j as DeleGatorCore, index$k as DelegationManager, index$i as EIP712, index$g as ERC20PeriodTransferEnforcer, index$f as ERC20StreamingEnforcer, index$e as ERC20TransferAmountEnforcer, index$h as EntryPoint, index$d as HybridDeleGator, index$c as IdEnforcer, type index_InitializedClient as InitializedClient, index$b as LimitedCallsEnforcer, index$a as MultiSigDeleGator, index$9 as MultiTokenPeriodEnforcer, index$8 as NativeTokenPeriodTransferEnforcer, index$7 as NativeTokenStreamingEnforcer, index$6 as NativeTokenTransferAmountEnforcer, index$5 as NonceEnforcer, index$4 as Ownable2Step, type index_P256Owner as P256Owner, index$3 as Pausable, index$2 as SimpleFactory, index$1 as SpecificActionERC20TransferBatchEnforcer, index_encodeProxyCreationCode as encodeProxyCreationCode, index_isContractDeployed as isContractDeployed, index_isImplementationExpected as isImplementationExpected };
22135
22135
  }
22136
22136
 
22137
- export { type InitializedClient as I, type P256Owner as P, index$k as a, index$j as b, index$i as c, index$h as d, index$d as e, index$c as f, index$b as g, index$a as h, index as i, index$5 as j, index$4 as k, index$3 as l, index$2 as m, index$1 as n, index$g as o, index$f as p, index$e as q, index$9 as r, index$8 as s, index$7 as t, index$6 as u, isContractDeployed as v, isImplementationExpected as w, encodeProxyCreationCode as x };
22137
+ export { type InitializedClient as I, type P256Owner as P, index$j as a, index$k as b, index$i as c, index$g as d, index$f as e, index$e as f, index$h as g, index$d as h, index as i, index$c as j, index$b as k, index$a as l, index$9 as m, index$8 as n, index$7 as o, index$6 as p, index$5 as q, index$4 as r, index$3 as s, index$2 as t, index$1 as u, encodeProxyCreationCode as v, isContractDeployed as w, isImplementationExpected as x };
@@ -1,7 +1,7 @@
1
1
  import { 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, SendTransactionRequest, SendTransactionParameters, OneOf, PublicClient, WalletClient } from 'viem';
2
+ import { Address, Hex, Client, Transport, Chain, Account, RpcSchema, OneOf, PublicClient, SendTransactionRequest, SendTransactionParameters, WalletClient } from 'viem';
3
3
  import { SmartAccount, SendUserOperationParameters } from 'viem/account-abstraction';
4
- import { P as PermissionContext, l as Call, S as SmartAccountsEnvironment, D as Delegation } from './types-BLYWtcR3.js';
4
+ import { l as Call, P as PermissionContext, S as SmartAccountsEnvironment, D as Delegation } from './types-BWaH4KH1.js';
5
5
  import { U as UserOperationV07 } from './userOp-DKgjzz7B.js';
6
6
 
7
7
  type BasePermission = {
@@ -268,4 +268,4 @@ declare namespace index {
268
268
  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, 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 };
269
269
  }
270
270
 
271
- export { type SupportedPermissionInfo as A, type PermissionTypes as B, type CaveatEnforcerParams as C, type NativeTokenPeriodicPermission as D, type Erc7715Client as E, type Erc20TokenStreamPermission as F, type GetSupportedExecutionPermissionsResult as G, type Erc20TokenPeriodicPermission as H, type Erc20TokenRevocationPermission as I, type RpcGetSupportedExecutionPermissionsResult as J, type RpcGetGrantedExecutionPermissionsResult as K, type RpcSupportedPermissionInfo as L, type MetaMaskExtensionClient as M, type NativeTokenStreamPermission as N, type DelegatedCall as O, type PeriodTransferResult as P, type RequestExecutionPermissionsParameters as R, type StreamingResult as S, erc7710WalletActions as a, erc7710BundlerActions as b, caveatEnforcerActions as c, getErc20StreamingEnforcerAvailableAmount as d, erc7715ProviderActions as e, getMultiTokenPeriodEnforcerAvailableAmount as f, getErc20PeriodTransferEnforcerAvailableAmount as g, getNativeTokenPeriodTransferEnforcerAvailableAmount as h, index as i, getNativeTokenStreamingEnforcerAvailableAmount as j, isValid7702Implementation as k, signDelegationActions as l, type SignDelegationParameters as m, type SignDelegationReturnType as n, signUserOperation as o, signUserOperationActions as p, type SignUserOperationParameters as q, type SignUserOperationReturnType as r, signDelegation as s, erc7715RequestExecutionPermissionsAction as t, type MetaMaskExtensionSchema as u, type RequestExecutionPermissionsReturnType as v, type PermissionRequestParameter as w, erc7715GetSupportedExecutionPermissionsAction as x, erc7715GetGrantedExecutionPermissionsAction as y, type GetGrantedExecutionPermissionsResult as z };
271
+ export { getNativeTokenPeriodTransferEnforcerAvailableAmount as A, getNativeTokenStreamingEnforcerAvailableAmount as B, type CaveatEnforcerParams as C, type DelegatedCall as D, type Erc20TokenPeriodicPermission as E, erc7715GetSupportedExecutionPermissionsAction as F, type GetGrantedExecutionPermissionsResult as G, isValid7702Implementation as H, erc7715RequestExecutionPermissionsAction as I, signDelegation as J, signDelegationActions as K, signUserOperation as L, type MetaMaskExtensionClient as M, type NativeTokenPeriodicPermission as N, signUserOperationActions as O, type PeriodTransferResult as P, type RequestExecutionPermissionsParameters as R, type SignDelegationParameters as S, type Erc20TokenRevocationPermission as a, type Erc20TokenStreamPermission as b, caveatEnforcerActions as c, type Erc7715Client as d, type GetSupportedExecutionPermissionsResult as e, type MetaMaskExtensionSchema as f, type NativeTokenStreamPermission as g, type PermissionRequestParameter as h, index as i, type PermissionTypes as j, type RequestExecutionPermissionsReturnType as k, type RpcGetGrantedExecutionPermissionsResult as l, type RpcGetSupportedExecutionPermissionsResult as m, type RpcSupportedPermissionInfo as n, type SignDelegationReturnType as o, type SignUserOperationParameters as p, type SignUserOperationReturnType as q, type StreamingResult as r, type SupportedPermissionInfo as s, erc7710BundlerActions as t, erc7710WalletActions as u, erc7715ProviderActions as v, getErc20PeriodTransferEnforcerAvailableAmount as w, getErc20StreamingEnforcerAvailableAmount as x, erc7715GetGrantedExecutionPermissionsAction as y, getMultiTokenPeriodEnforcerAvailableAmount as z };
@@ -1,8 +1,8 @@
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 { p as DelegationStruct, E as ExecutionMode, e as ExecutionStruct } from './delegation-D_TY-tAq.cjs';
5
- import { D as Delegation, P as PermissionContext } from './types-BLYWtcR3.cjs';
4
+ import { m as DelegationStruct, E as ExecutionMode, d as ExecutionStruct } from './delegation-DgmIOh21.js';
5
+ import { D as Delegation, P as PermissionContext } from './types-BWaH4KH1.js';
6
6
 
7
7
  declare const NAME$1 = "DelegationManager";
8
8
  declare const VERSION$1 = "1.3.0";
@@ -22134,4 +22134,4 @@ declare namespace index {
22134
22134
  export { index$j as DeleGatorCore, index$k as DelegationManager, index$i as EIP712, index$g as ERC20PeriodTransferEnforcer, index$f as ERC20StreamingEnforcer, index$e as ERC20TransferAmountEnforcer, index$h as EntryPoint, index$d as HybridDeleGator, index$c as IdEnforcer, type index_InitializedClient as InitializedClient, index$b as LimitedCallsEnforcer, index$a as MultiSigDeleGator, index$9 as MultiTokenPeriodEnforcer, index$8 as NativeTokenPeriodTransferEnforcer, index$7 as NativeTokenStreamingEnforcer, index$6 as NativeTokenTransferAmountEnforcer, index$5 as NonceEnforcer, index$4 as Ownable2Step, type index_P256Owner as P256Owner, index$3 as Pausable, index$2 as SimpleFactory, index$1 as SpecificActionERC20TransferBatchEnforcer, index_encodeProxyCreationCode as encodeProxyCreationCode, index_isContractDeployed as isContractDeployed, index_isImplementationExpected as isImplementationExpected };
22135
22135
  }
22136
22136
 
22137
- export { type InitializedClient as I, type P256Owner as P, index$k as a, index$j as b, index$i as c, index$h as d, index$d as e, index$c as f, index$b as g, index$a as h, index as i, index$5 as j, index$4 as k, index$3 as l, index$2 as m, index$1 as n, index$g as o, index$f as p, index$e as q, index$9 as r, index$8 as s, index$7 as t, index$6 as u, isContractDeployed as v, isImplementationExpected as w, encodeProxyCreationCode as x };
22137
+ export { type InitializedClient as I, type P256Owner as P, index$j as a, index$k as b, index$i as c, index$g as d, index$f as e, index$e as f, index$h as g, index$d as h, index as i, index$c as j, index$b as k, index$a as l, index$9 as m, index$8 as n, index$7 as o, index$6 as p, index$5 as q, index$4 as r, index$3 as s, index$2 as t, index$1 as u, encodeProxyCreationCode as v, isContractDeployed as w, isImplementationExpected as x };
@@ -1,7 +1,7 @@
1
1
  import { 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, SendTransactionRequest, SendTransactionParameters, OneOf, PublicClient, WalletClient } from 'viem';
2
+ import { Address, Hex, Client, Transport, Chain, Account, RpcSchema, OneOf, PublicClient, SendTransactionRequest, SendTransactionParameters, WalletClient } from 'viem';
3
3
  import { SmartAccount, SendUserOperationParameters } from 'viem/account-abstraction';
4
- import { P as PermissionContext, l as Call, S as SmartAccountsEnvironment, D as Delegation } from './types-BLYWtcR3.cjs';
4
+ import { l as Call, P as PermissionContext, S as SmartAccountsEnvironment, D as Delegation } from './types-BWaH4KH1.cjs';
5
5
  import { U as UserOperationV07 } from './userOp-DKgjzz7B.cjs';
6
6
 
7
7
  type BasePermission = {
@@ -268,4 +268,4 @@ declare namespace index {
268
268
  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, 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 };
269
269
  }
270
270
 
271
- export { type SupportedPermissionInfo as A, type PermissionTypes as B, type CaveatEnforcerParams as C, type NativeTokenPeriodicPermission as D, type Erc7715Client as E, type Erc20TokenStreamPermission as F, type GetSupportedExecutionPermissionsResult as G, type Erc20TokenPeriodicPermission as H, type Erc20TokenRevocationPermission as I, type RpcGetSupportedExecutionPermissionsResult as J, type RpcGetGrantedExecutionPermissionsResult as K, type RpcSupportedPermissionInfo as L, type MetaMaskExtensionClient as M, type NativeTokenStreamPermission as N, type DelegatedCall as O, type PeriodTransferResult as P, type RequestExecutionPermissionsParameters as R, type StreamingResult as S, erc7710WalletActions as a, erc7710BundlerActions as b, caveatEnforcerActions as c, getErc20StreamingEnforcerAvailableAmount as d, erc7715ProviderActions as e, getMultiTokenPeriodEnforcerAvailableAmount as f, getErc20PeriodTransferEnforcerAvailableAmount as g, getNativeTokenPeriodTransferEnforcerAvailableAmount as h, index as i, getNativeTokenStreamingEnforcerAvailableAmount as j, isValid7702Implementation as k, signDelegationActions as l, type SignDelegationParameters as m, type SignDelegationReturnType as n, signUserOperation as o, signUserOperationActions as p, type SignUserOperationParameters as q, type SignUserOperationReturnType as r, signDelegation as s, erc7715RequestExecutionPermissionsAction as t, type MetaMaskExtensionSchema as u, type RequestExecutionPermissionsReturnType as v, type PermissionRequestParameter as w, erc7715GetSupportedExecutionPermissionsAction as x, erc7715GetGrantedExecutionPermissionsAction as y, type GetGrantedExecutionPermissionsResult as z };
271
+ export { getNativeTokenPeriodTransferEnforcerAvailableAmount as A, getNativeTokenStreamingEnforcerAvailableAmount as B, type CaveatEnforcerParams as C, type DelegatedCall as D, type Erc20TokenPeriodicPermission as E, erc7715GetSupportedExecutionPermissionsAction as F, type GetGrantedExecutionPermissionsResult as G, isValid7702Implementation as H, erc7715RequestExecutionPermissionsAction as I, signDelegation as J, signDelegationActions as K, signUserOperation as L, type MetaMaskExtensionClient as M, type NativeTokenPeriodicPermission as N, signUserOperationActions as O, type PeriodTransferResult as P, type RequestExecutionPermissionsParameters as R, type SignDelegationParameters as S, type Erc20TokenRevocationPermission as a, type Erc20TokenStreamPermission as b, caveatEnforcerActions as c, type Erc7715Client as d, type GetSupportedExecutionPermissionsResult as e, type MetaMaskExtensionSchema as f, type NativeTokenStreamPermission as g, type PermissionRequestParameter as h, index as i, type PermissionTypes as j, type RequestExecutionPermissionsReturnType as k, type RpcGetGrantedExecutionPermissionsResult as l, type RpcGetSupportedExecutionPermissionsResult as m, type RpcSupportedPermissionInfo as n, type SignDelegationReturnType as o, type SignUserOperationParameters as p, type SignUserOperationReturnType as q, type StreamingResult as r, type SupportedPermissionInfo as s, erc7710BundlerActions as t, erc7710WalletActions as u, erc7715ProviderActions as v, getErc20PeriodTransferEnforcerAvailableAmount as w, getErc20StreamingEnforcerAvailableAmount as x, erc7715GetGrantedExecutionPermissionsAction as y, getMultiTokenPeriodEnforcerAvailableAmount as z };
package/dist/index.cjs CHANGED
@@ -5,15 +5,14 @@
5
5
  var _chunkQMRKCB7Tcjs = require('./chunk-QMRKCB7T.cjs');
6
6
 
7
7
 
8
-
9
- var _chunkXN36L4RXcjs = require('./chunk-XN36L4RX.cjs');
8
+ var _chunkF2RG26RHcjs = require('./chunk-F2RG26RH.cjs');
10
9
  require('./chunk-UUOH2WAW.cjs');
11
10
 
12
11
 
13
12
 
14
13
 
15
14
 
16
- var _chunkDLD377CNcjs = require('./chunk-DLD377CN.cjs');
15
+ var _chunkBYWRJGSKcjs = require('./chunk-BYWRJGSK.cjs');
17
16
 
18
17
 
19
18
 
@@ -115,15 +114,15 @@ var resolveHybridSigner = (config) => {
115
114
  if (webAuthnAccount.type !== "webAuthn") {
116
115
  throw new Error("Account is not a webAuthn account");
117
116
  }
118
- const encodeSignature = ({ signature, webauthn }) => _chunkDLD377CNcjs.encodeDeleGatorSignature.call(void 0,
117
+ const encodeSignature = (result) => _chunkBYWRJGSKcjs.encodeDeleGatorSignature.call(void 0,
119
118
  keyId,
120
- signature,
121
- webauthn.clientDataJSON,
122
- webauthn.authenticatorData
119
+ result.signature,
120
+ result.webauthn.clientDataJSON,
121
+ result.webauthn.authenticatorData
123
122
  );
124
123
  const signMessage = async (args) => webAuthnAccount.signMessage(args).then(encodeSignature);
125
124
  const signTypedData = async (typedDataDefinition) => webAuthnAccount.signTypedData(typedDataDefinition).then(encodeSignature);
126
- const getStubSignature = async () => _chunkDLD377CNcjs.createDummyWebAuthnSignature.call(void 0, keyId);
125
+ const getStubSignature = async () => _chunkBYWRJGSKcjs.createDummyWebAuthnSignature.call(void 0, keyId);
127
126
  return {
128
127
  signMessage,
129
128
  signTypedData,
@@ -210,19 +209,20 @@ var resolveStateless7702Signer = (config) => {
210
209
  }
211
210
  throw new Error("Invalid signer config");
212
211
  };
213
- var resolveSigner = (config) => {
214
- const { implementation } = config;
212
+ function resolveSigner(config) {
213
+ const { implementation, signer } = config;
214
+ if (!signer) {
215
+ return null;
216
+ }
215
217
  if (implementation === "Hybrid" /* Hybrid */) {
216
- return resolveHybridSigner(config.signer);
218
+ return resolveHybridSigner(signer);
217
219
  } else if (implementation === "MultiSig" /* MultiSig */) {
218
- return resolveMultiSigSigner(config.signer);
220
+ return resolveMultiSigSigner(signer);
219
221
  } else if (implementation === "Stateless7702" /* Stateless7702 */) {
220
- return resolveStateless7702Signer(
221
- config.signer
222
- );
222
+ return resolveStateless7702Signer(signer);
223
223
  }
224
224
  throw new Error(`Implementation type '${implementation}' not supported`);
225
- };
225
+ }
226
226
 
227
227
  // src/toMetaMaskSmartAccount.ts
228
228
  var ENTRYPOINT_VERSION = "0.7";
@@ -230,7 +230,8 @@ async function toMetaMaskSmartAccount(params) {
230
230
  const {
231
231
  client,
232
232
  client: { chain },
233
- implementation
233
+ implementation,
234
+ nonceKeyManager
234
235
  } = params;
235
236
  if (!chain) {
236
237
  throw new Error("Chain not specified");
@@ -248,7 +249,7 @@ async function toMetaMaskSmartAccount(params) {
248
249
  if (implementation === "Stateless7702" /* Stateless7702 */) {
249
250
  throw new Error("Stateless7702 does not support counterfactual accounts");
250
251
  }
251
- const accountData = await _chunkDLD377CNcjs.getCounterfactualAccountData.call(void 0, {
252
+ const accountData = await _chunkBYWRJGSKcjs.getCounterfactualAccountData.call(void 0, {
252
253
  factory: environment.SimpleFactory,
253
254
  implementations: environment.implementations,
254
255
  implementation,
@@ -289,6 +290,11 @@ async function toMetaMaskSmartAccount(params) {
289
290
  };
290
291
  };
291
292
  const signDelegation2 = async (delegationParams) => {
293
+ if (!signer) {
294
+ throw new Error(
295
+ "Cannot sign delegation: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations."
296
+ );
297
+ }
292
298
  const { delegation, chainId } = delegationParams;
293
299
  const delegationStruct = _chunkYDLLC6PPcjs.toDelegationStruct.call(void 0, {
294
300
  ...delegation,
@@ -308,6 +314,11 @@ async function toMetaMaskSmartAccount(params) {
308
314
  return signature;
309
315
  };
310
316
  const signUserOperation2 = async (userOpParams) => {
317
+ if (!signer) {
318
+ throw new Error(
319
+ "Cannot sign user operation: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations."
320
+ );
321
+ }
311
322
  const { chainId } = userOpParams;
312
323
  const packedUserOp = _accountabstraction.toPackedUserOperation.call(void 0, {
313
324
  sender: address,
@@ -328,13 +339,24 @@ async function toMetaMaskSmartAccount(params) {
328
339
  return signature;
329
340
  };
330
341
  const getAddress = async () => address;
331
- const getNonce = async () => _chunkXN36L4RXcjs.read.call(void 0, {
332
- client,
333
- entryPoint: environment.EntryPoint,
334
- contractAddress: address,
335
- key: 0n
336
- });
337
- const encodeCalls = async (calls) => _chunkDLD377CNcjs.encodeCallsForCaller.call(void 0, address, calls);
342
+ const encodeCalls = async (calls) => _chunkBYWRJGSKcjs.encodeCallsForCaller.call(void 0, address, calls);
343
+ const signerMethods = _nullishCoalesce(signer, () => ( {
344
+ signMessage: async () => {
345
+ throw new Error(
346
+ "Cannot sign message: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations."
347
+ );
348
+ },
349
+ signTypedData: async () => {
350
+ throw new Error(
351
+ "Cannot sign typed data: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations."
352
+ );
353
+ },
354
+ getStubSignature: async () => {
355
+ throw new Error(
356
+ "Cannot get stub signature: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations."
357
+ );
358
+ }
359
+ }));
338
360
  const smartAccount = await _accountabstraction.toSmartAccount.call(void 0, {
339
361
  abi,
340
362
  client,
@@ -343,10 +365,10 @@ async function toMetaMaskSmartAccount(params) {
343
365
  getAddress,
344
366
  getFactoryArgs,
345
367
  encodeCalls,
346
- getNonce,
347
368
  signUserOperation: signUserOperation2,
348
369
  signDelegation: signDelegation2,
349
- ...signer
370
+ nonceKeyManager,
371
+ ...signerMethods
350
372
  });
351
373
  if (implementation === "Stateless7702" /* Stateless7702 */) {
352
374
  return {
@@ -422,5 +444,5 @@ function createInfuraBundlerClient(config) {
422
444
 
423
445
 
424
446
 
425
- exports.ANY_BENEFICIARY = _chunkYDLLC6PPcjs.ANY_BENEFICIARY; exports.BalanceChangeType = _chunkYDLLC6PPcjs.BalanceChangeType; exports.CaveatType = _chunkYDLLC6PPcjs.CaveatType; exports.ExecutionMode = _chunkVLKX4BR6cjs.ExecutionMode; exports.Implementation = _chunkYDLLC6PPcjs.Implementation; exports.PREFERRED_VERSION = _chunkSOFB2MXGcjs.PREFERRED_VERSION; exports.ROOT_AUTHORITY = _chunkYDLLC6PPcjs.ROOT_AUTHORITY; exports.ScopeType = _chunkYDLLC6PPcjs.ScopeType; exports.TransferWindow = _chunkYDLLC6PPcjs.TransferWindow; exports.actions = _chunkQMRKCB7Tcjs.actions_exports; exports.aggregateSignature = aggregateSignature; exports.contracts = _chunkXN36L4RXcjs.contracts_exports; exports.createCaveat = _chunkYDLLC6PPcjs.createCaveat; exports.createCaveatEnforcerClient = createCaveatEnforcerClient; exports.createDelegation = _chunkYDLLC6PPcjs.createDelegation; exports.createExecution = _chunkVLKX4BR6cjs.createExecution; exports.createInfuraBundlerClient = createInfuraBundlerClient; exports.createOpenDelegation = _chunkYDLLC6PPcjs.createOpenDelegation; exports.getSmartAccountsEnvironment = _chunkSOFB2MXGcjs.getSmartAccountsEnvironment; exports.signDelegation = _chunkYDLLC6PPcjs.signDelegation; exports.signUserOperation = _chunkSOFB2MXGcjs.signUserOperation; exports.toMetaMaskSmartAccount = toMetaMaskSmartAccount;
447
+ exports.ANY_BENEFICIARY = _chunkYDLLC6PPcjs.ANY_BENEFICIARY; exports.BalanceChangeType = _chunkYDLLC6PPcjs.BalanceChangeType; exports.CaveatType = _chunkYDLLC6PPcjs.CaveatType; exports.ExecutionMode = _chunkVLKX4BR6cjs.ExecutionMode; exports.Implementation = _chunkYDLLC6PPcjs.Implementation; exports.PREFERRED_VERSION = _chunkSOFB2MXGcjs.PREFERRED_VERSION; exports.ROOT_AUTHORITY = _chunkYDLLC6PPcjs.ROOT_AUTHORITY; exports.ScopeType = _chunkYDLLC6PPcjs.ScopeType; exports.TransferWindow = _chunkYDLLC6PPcjs.TransferWindow; exports.actions = _chunkQMRKCB7Tcjs.actions_exports; exports.aggregateSignature = aggregateSignature; exports.contracts = _chunkF2RG26RHcjs.contracts_exports; exports.createCaveat = _chunkYDLLC6PPcjs.createCaveat; exports.createCaveatEnforcerClient = createCaveatEnforcerClient; exports.createDelegation = _chunkYDLLC6PPcjs.createDelegation; exports.createExecution = _chunkVLKX4BR6cjs.createExecution; exports.createInfuraBundlerClient = createInfuraBundlerClient; exports.createOpenDelegation = _chunkYDLLC6PPcjs.createOpenDelegation; exports.getSmartAccountsEnvironment = _chunkSOFB2MXGcjs.getSmartAccountsEnvironment; exports.signDelegation = _chunkYDLLC6PPcjs.signDelegation; exports.signUserOperation = _chunkSOFB2MXGcjs.signUserOperation; exports.toMetaMaskSmartAccount = toMetaMaskSmartAccount;
426
448
  //# sourceMappingURL=index.cjs.map
@@ -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;AACA;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;AC3CA;AACE;AACA;AACA;AAAA,2DACK;AAEP;AACE;AACA;AACA;AAAA,8DACK;AD4CP;AACA;AEvDA,4BAAuB;AFyDvB;AACA;AGzDA;AAEA,IAAM,eAAA,EAAiB,CAAC,OAAO,CAAA;AAoBxB,IAAM,mBAAA,EAAqB,CAAC;AAAA,EACjC;AACF,CAAA,EAAA,GAEW;AACT,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,CAAA,CAAA;AACjD,IAAA;AACF,EAAA;AAGyC,EAAA;AACR,IAAA;AACjC,EAAA;AAGgD,EAAA;AAClD;AHgCsD;AACA;AEnDpD;AAImB;AACZ,EAAA;AAC4B,IAAA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,QAAA;AACG,QAAA;AACsB,QAAA;AACjC,MAAA;AACO,MAAA;AACM,MAAA;AACJ,MAAA;AACV,IAAA;AAEM,IAAA;AACT,EAAA;AAE2E,EAAA;AACrD,IAAA;AAEuB,IAAA;AACjC,MAAA;AACL,MAAA;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;AAGnB,EAAA;AACR,IAAA;AACwB,IAAA;AACP,IAAA;AACZ,IAAA;AACN,EAAA;AAGD,EAAA;AAEwC,EAAA;AACxC,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACAG,IAAAA;AACAC,IAAAA;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;ADkJsD;AACA;AI3UpD;AACA,EAAA;AACA,EAAA;AAIqD;AACR,EAAA;AAC/C;AJ0UsD;AACA;AKlXtD;AACE;AAIK;AAyCiD;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;AAEC,EAAA;AAG3B,EAAA;AACF,IAAA;AACvB,EAAA;AACF;ALuQsD;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 { Implementation } from './constants';\nimport { getCounterfactualAccountData } from './counterfactualAccountData';\nimport {\n SIGNABLE_DELEGATION_TYPED_DATA,\n toDelegationStruct,\n} from './delegation';\nimport { entryPointGetNonce as _getNonce } from './DelegationFramework/EntryPoint/read';\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 } = params;\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 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 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 getNonce = async () =>\n _getNonce({\n client,\n entryPoint: environment.EntryPoint,\n contractAddress: address,\n key: 0n,\n });\n\n const encodeCalls = async (calls: readonly Call[]) =>\n encodeCallsForCaller(address, calls);\n\n const smartAccount = await toSmartAccount({\n abi,\n client,\n entryPoint,\n environment,\n getAddress,\n getFactoryArgs,\n encodeCalls,\n getNonce,\n signUserOperation,\n signDelegation,\n ...signer,\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 { SignReturnType as WebAuthnSignReturnType } from 'webauthn-p256';\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 = ({ signature, webauthn }: WebAuthnSignReturnType) =>\n encodeDeleGatorSignature(\n keyId,\n signature,\n webauthn.clientDataJSON,\n 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\nexport const resolveSigner = <TImplementation extends Implementation>(config: {\n implementation: TImplementation;\n signer: SignerConfigByImplementation<TImplementation>;\n}): InternalSigner => {\n const { implementation } = config;\n\n if (implementation === Implementation.Hybrid) {\n return resolveHybridSigner(config.signer as HybridSignerConfig);\n } else if (implementation === Implementation.MultiSig) {\n return resolveMultiSigSigner(config.signer as MultiSigSignerConfig);\n } else if (implementation === Implementation.Stateless7702) {\n return resolveStateless7702Signer(\n config.signer as Stateless7702SignerConfig,\n );\n }\n throw new Error(`Implementation type '${implementation}' not supported`);\n};\n","import type { Address, Hex } from 'viem';\nimport { concat } from 'viem';\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 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 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 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\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 // 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/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;AAEA,IAAM,eAAA,EAAiB,CAAC,OAAO,CAAA;AAoBxB,IAAM,mBAAA,EAAqB,CAAC;AAAA,EACjC;AACF,CAAA,EAAA,GAEW;AACT,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,c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;ADkJsD;AACA;AIjWpD;AACA,EAAA;AACA,EAAA;AAIqD;AACR,EAAA;AAC/C;AJgWsD;AACA;AKxYtD;AACE;AAIK;AAyCiD;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;AAEC,EAAA;AAG3B,EAAA;AACF,IAAA;AACvB,EAAA;AACF;AL6RsD;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 { 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 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\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 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 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 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\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 // 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,13 +1,13 @@
1
- import { I as Implementation, T as ToMetaMaskSmartAccountParameters, a as ToMetaMaskSmartAccountReturnType, C as Caveat, S as SmartAccountsEnvironment } from './types-BLYWtcR3.cjs';
2
- export { A as AccountSignerConfig, k as CaveatType, D as Delegation, H as HybridDeleGatorDeployParams, g as HybridSignerConfig, e as MetaMaskSmartAccount, d as MetaMaskSmartAccountImplementation, M as MultiSigDeleGatorDeployParams, h as MultiSigSignerConfig, P as PermissionContext, j as ScopeType, c as SignDelegationParams, b as SignUserOperationParams, i as TransferWindow, W as WalletSignerConfig, f as WebAuthnSignerConfig } from './types-BLYWtcR3.cjs';
3
- export { B as BalanceChangeType, g as Caveats, C as CreateDelegationOptions, f as CreateExecutionArgs, b as CreateOpenDelegationOptions, E as ExecutionMode, e as ExecutionStruct, c as createDelegation, d as createExecution, a as createOpenDelegation, s as signDelegation } from './delegation-D_TY-tAq.cjs';
4
- export { P as PREFERRED_VERSION, g as getSmartAccountsEnvironment } from './smartAccountsEnvironment-BU8kjlEv.cjs';
1
+ import { I as Implementation, T as ToMetaMaskSmartAccountParameters, a as ToMetaMaskSmartAccountReturnType, C as Caveat, S as SmartAccountsEnvironment } from './types-BWaH4KH1.cjs';
2
+ export { A as AccountSignerConfig, b as CaveatType, D as Delegation, H as HybridDeleGatorDeployParams, c as HybridSignerConfig, M as MetaMaskSmartAccount, d as MetaMaskSmartAccountImplementation, e as MultiSigDeleGatorDeployParams, f as MultiSigSignerConfig, P as PermissionContext, g as ScopeType, h as SignDelegationParams, i as SignUserOperationParams, j as TransferWindow, W as WalletSignerConfig, k as WebAuthnSignerConfig } from './types-BWaH4KH1.cjs';
3
+ export { B as BalanceChangeType, C as Caveats, a as CreateDelegationOptions, b as CreateExecutionArgs, c as CreateOpenDelegationOptions, E as ExecutionMode, d as ExecutionStruct, e as createDelegation, f as createExecution, g as createOpenDelegation, s as signDelegation } from './delegation-Ci3me5Rg.cjs';
4
+ export { P as PREFERRED_VERSION, g as getSmartAccountsEnvironment } from './smartAccountsEnvironment-BIcho7e0.cjs';
5
5
  import { Hex, Address, Transport, Chain, Account, Client } from 'viem';
6
6
  export { s as signUserOperation } from './userOp-DKgjzz7B.cjs';
7
- export { i as contracts } from './index-DvcKJcXi.cjs';
8
- import { c as caveatEnforcerActions } from './index-CZes99jV.cjs';
9
- export { i as actions } from './index-CZes99jV.cjs';
10
- import { SmartAccount, BundlerClientConfig, BundlerClient } from 'viem/account-abstraction';
7
+ export { i as contracts } from './index-CSjEW7MJ.cjs';
8
+ import { c as caveatEnforcerActions } from './index-Uj_xXVko.cjs';
9
+ export { i as actions } from './index-Uj_xXVko.cjs';
10
+ import { SmartAccount, BundlerClient, BundlerClientConfig } from 'viem/account-abstraction';
11
11
  export { ANY_BENEFICIARY, ROOT_AUTHORITY } from '@metamask/delegation-core';
12
12
  import '@metamask/delegation-abis';
13
13
  import 'viem/chains';
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import { I as Implementation, T as ToMetaMaskSmartAccountParameters, a as ToMetaMaskSmartAccountReturnType, C as Caveat, S as SmartAccountsEnvironment } from './types-BLYWtcR3.js';
2
- export { A as AccountSignerConfig, k as CaveatType, D as Delegation, H as HybridDeleGatorDeployParams, g as HybridSignerConfig, e as MetaMaskSmartAccount, d as MetaMaskSmartAccountImplementation, M as MultiSigDeleGatorDeployParams, h as MultiSigSignerConfig, P as PermissionContext, j as ScopeType, c as SignDelegationParams, b as SignUserOperationParams, i as TransferWindow, W as WalletSignerConfig, f as WebAuthnSignerConfig } from './types-BLYWtcR3.js';
3
- export { B as BalanceChangeType, g as Caveats, C as CreateDelegationOptions, f as CreateExecutionArgs, b as CreateOpenDelegationOptions, E as ExecutionMode, e as ExecutionStruct, c as createDelegation, d as createExecution, a as createOpenDelegation, s as signDelegation } from './delegation-DGUfyX-C.js';
4
- export { P as PREFERRED_VERSION, g as getSmartAccountsEnvironment } from './smartAccountsEnvironment-egxuflDO.js';
1
+ import { I as Implementation, T as ToMetaMaskSmartAccountParameters, a as ToMetaMaskSmartAccountReturnType, C as Caveat, S as SmartAccountsEnvironment } from './types-BWaH4KH1.js';
2
+ export { A as AccountSignerConfig, b as CaveatType, D as Delegation, H as HybridDeleGatorDeployParams, c as HybridSignerConfig, M as MetaMaskSmartAccount, d as MetaMaskSmartAccountImplementation, e as MultiSigDeleGatorDeployParams, f as MultiSigSignerConfig, P as PermissionContext, g as ScopeType, h as SignDelegationParams, i as SignUserOperationParams, j as TransferWindow, W as WalletSignerConfig, k as WebAuthnSignerConfig } from './types-BWaH4KH1.js';
3
+ export { B as BalanceChangeType, C as Caveats, a as CreateDelegationOptions, b as CreateExecutionArgs, c as CreateOpenDelegationOptions, E as ExecutionMode, d as ExecutionStruct, e as createDelegation, f as createExecution, g as createOpenDelegation, s as signDelegation } from './delegation-DgmIOh21.js';
4
+ export { P as PREFERRED_VERSION, g as getSmartAccountsEnvironment } from './smartAccountsEnvironment-Bso0CIWt.js';
5
5
  import { Hex, Address, Transport, Chain, Account, Client } from 'viem';
6
6
  export { s as signUserOperation } from './userOp-DKgjzz7B.js';
7
- export { i as contracts } from './index-B9bsjGqI.js';
8
- import { c as caveatEnforcerActions } from './index-FpCh2419.js';
9
- export { i as actions } from './index-FpCh2419.js';
10
- import { SmartAccount, BundlerClientConfig, BundlerClient } from 'viem/account-abstraction';
7
+ export { i as contracts } from './index-UF6eCzBC.js';
8
+ import { c as caveatEnforcerActions } from './index-D7fBuNV-.js';
9
+ export { i as actions } from './index-D7fBuNV-.js';
10
+ import { SmartAccount, BundlerClient, BundlerClientConfig } from 'viem/account-abstraction';
11
11
  export { ANY_BENEFICIARY, ROOT_AUTHORITY } from '@metamask/delegation-core';
12
12
  import '@metamask/delegation-abis';
13
13
  import 'viem/chains';
package/dist/index.mjs CHANGED
@@ -4,16 +4,15 @@ import {
4
4
  isValid7702Implementation
5
5
  } from "./chunk-NOCLGZGB.mjs";
6
6
  import {
7
- contracts_exports,
8
- read
9
- } from "./chunk-33AMUJBJ.mjs";
7
+ contracts_exports
8
+ } from "./chunk-YSBBRLMT.mjs";
10
9
  import "./chunk-YTELOQ4I.mjs";
11
10
  import {
12
11
  createDummyWebAuthnSignature,
13
12
  encodeCallsForCaller,
14
13
  encodeDeleGatorSignature,
15
14
  getCounterfactualAccountData
16
- } from "./chunk-WPVSFOQM.mjs";
15
+ } from "./chunk-45GHWVQA.mjs";
17
16
  import {
18
17
  PREFERRED_VERSION,
19
18
  SIGNABLE_USER_OP_TYPED_DATA,
@@ -115,11 +114,11 @@ var resolveHybridSigner = (config) => {
115
114
  if (webAuthnAccount.type !== "webAuthn") {
116
115
  throw new Error("Account is not a webAuthn account");
117
116
  }
118
- const encodeSignature = ({ signature, webauthn }) => encodeDeleGatorSignature(
117
+ const encodeSignature = (result) => encodeDeleGatorSignature(
119
118
  keyId,
120
- signature,
121
- webauthn.clientDataJSON,
122
- webauthn.authenticatorData
119
+ result.signature,
120
+ result.webauthn.clientDataJSON,
121
+ result.webauthn.authenticatorData
123
122
  );
124
123
  const signMessage = async (args) => webAuthnAccount.signMessage(args).then(encodeSignature);
125
124
  const signTypedData = async (typedDataDefinition) => webAuthnAccount.signTypedData(typedDataDefinition).then(encodeSignature);
@@ -210,19 +209,20 @@ var resolveStateless7702Signer = (config) => {
210
209
  }
211
210
  throw new Error("Invalid signer config");
212
211
  };
213
- var resolveSigner = (config) => {
214
- const { implementation } = config;
212
+ function resolveSigner(config) {
213
+ const { implementation, signer } = config;
214
+ if (!signer) {
215
+ return null;
216
+ }
215
217
  if (implementation === "Hybrid" /* Hybrid */) {
216
- return resolveHybridSigner(config.signer);
218
+ return resolveHybridSigner(signer);
217
219
  } else if (implementation === "MultiSig" /* MultiSig */) {
218
- return resolveMultiSigSigner(config.signer);
220
+ return resolveMultiSigSigner(signer);
219
221
  } else if (implementation === "Stateless7702" /* Stateless7702 */) {
220
- return resolveStateless7702Signer(
221
- config.signer
222
- );
222
+ return resolveStateless7702Signer(signer);
223
223
  }
224
224
  throw new Error(`Implementation type '${implementation}' not supported`);
225
- };
225
+ }
226
226
 
227
227
  // src/toMetaMaskSmartAccount.ts
228
228
  var ENTRYPOINT_VERSION = "0.7";
@@ -230,7 +230,8 @@ async function toMetaMaskSmartAccount(params) {
230
230
  const {
231
231
  client,
232
232
  client: { chain },
233
- implementation
233
+ implementation,
234
+ nonceKeyManager
234
235
  } = params;
235
236
  if (!chain) {
236
237
  throw new Error("Chain not specified");
@@ -289,6 +290,11 @@ async function toMetaMaskSmartAccount(params) {
289
290
  };
290
291
  };
291
292
  const signDelegation2 = async (delegationParams) => {
293
+ if (!signer) {
294
+ throw new Error(
295
+ "Cannot sign delegation: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations."
296
+ );
297
+ }
292
298
  const { delegation, chainId } = delegationParams;
293
299
  const delegationStruct = toDelegationStruct({
294
300
  ...delegation,
@@ -308,6 +314,11 @@ async function toMetaMaskSmartAccount(params) {
308
314
  return signature;
309
315
  };
310
316
  const signUserOperation2 = async (userOpParams) => {
317
+ if (!signer) {
318
+ throw new Error(
319
+ "Cannot sign user operation: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations."
320
+ );
321
+ }
311
322
  const { chainId } = userOpParams;
312
323
  const packedUserOp = toPackedUserOperation({
313
324
  sender: address,
@@ -328,13 +339,24 @@ async function toMetaMaskSmartAccount(params) {
328
339
  return signature;
329
340
  };
330
341
  const getAddress = async () => address;
331
- const getNonce = async () => read({
332
- client,
333
- entryPoint: environment.EntryPoint,
334
- contractAddress: address,
335
- key: 0n
336
- });
337
342
  const encodeCalls = async (calls) => encodeCallsForCaller(address, calls);
343
+ const signerMethods = signer ?? {
344
+ signMessage: async () => {
345
+ throw new Error(
346
+ "Cannot sign message: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations."
347
+ );
348
+ },
349
+ signTypedData: async () => {
350
+ throw new Error(
351
+ "Cannot sign typed data: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations."
352
+ );
353
+ },
354
+ getStubSignature: async () => {
355
+ throw new Error(
356
+ "Cannot get stub signature: signer not provided. Specify a signer in toMetaMaskSmartAccount() to perform signing operations."
357
+ );
358
+ }
359
+ };
338
360
  const smartAccount = await toSmartAccount({
339
361
  abi,
340
362
  client,
@@ -343,10 +365,10 @@ async function toMetaMaskSmartAccount(params) {
343
365
  getAddress,
344
366
  getFactoryArgs,
345
367
  encodeCalls,
346
- getNonce,
347
368
  signUserOperation: signUserOperation2,
348
369
  signDelegation: signDelegation2,
349
- ...signer
370
+ nonceKeyManager,
371
+ ...signerMethods
350
372
  });
351
373
  if (implementation === "Stateless7702" /* Stateless7702 */) {
352
374
  return {