@account-kit/smart-contracts 4.12.1-alpha.0 → 4.13.1-alpha.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 (63) hide show
  1. package/dist/esm/src/index.d.ts +5 -0
  2. package/dist/esm/src/index.js +2 -0
  3. package/dist/esm/src/index.js.map +1 -1
  4. package/dist/esm/src/ma-v2/account/common/modularAccountV2Base.d.ts +39 -0
  5. package/dist/esm/src/ma-v2/account/{semiModularAccountV2.js → common/modularAccountV2Base.js} +32 -61
  6. package/dist/esm/src/ma-v2/account/common/modularAccountV2Base.js.map +1 -0
  7. package/dist/esm/src/ma-v2/account/modularAccountV2.d.ts +16 -0
  8. package/dist/esm/src/ma-v2/account/modularAccountV2.js +113 -0
  9. package/dist/esm/src/ma-v2/account/modularAccountV2.js.map +1 -0
  10. package/dist/esm/src/ma-v2/account/nativeSMASigner.d.ts +1 -1
  11. package/dist/esm/src/ma-v2/account/nativeSMASigner.js +1 -1
  12. package/dist/esm/src/ma-v2/account/nativeSMASigner.js.map +1 -1
  13. package/dist/esm/src/ma-v2/actions/install-validation/installValidation.d.ts +11 -9
  14. package/dist/esm/src/ma-v2/actions/install-validation/installValidation.js +43 -23
  15. package/dist/esm/src/ma-v2/actions/install-validation/installValidation.js.map +1 -1
  16. package/dist/esm/src/ma-v2/client/client.d.ts +7 -6
  17. package/dist/esm/src/ma-v2/client/client.js +21 -18
  18. package/dist/esm/src/ma-v2/client/client.js.map +1 -1
  19. package/dist/esm/src/ma-v2/index.d.ts +0 -4
  20. package/dist/esm/src/ma-v2/index.js +0 -2
  21. package/dist/esm/src/ma-v2/index.js.map +1 -1
  22. package/dist/esm/src/ma-v2/modules/allowlist-module/module.d.ts +14 -0
  23. package/dist/esm/src/ma-v2/modules/allowlist-module/module.js +14 -0
  24. package/dist/esm/src/ma-v2/modules/allowlist-module/module.js.map +1 -1
  25. package/dist/esm/src/ma-v2/modules/single-signer-validation/signer.d.ts +1 -1
  26. package/dist/esm/src/ma-v2/modules/single-signer-validation/signer.js +1 -1
  27. package/dist/esm/src/ma-v2/modules/single-signer-validation/signer.js.map +1 -1
  28. package/dist/esm/src/ma-v2/modules/time-range-module/module.d.ts +10 -1
  29. package/dist/esm/src/ma-v2/modules/time-range-module/module.js +20 -0
  30. package/dist/esm/src/ma-v2/modules/time-range-module/module.js.map +1 -1
  31. package/dist/types/src/index.d.ts +5 -0
  32. package/dist/types/src/index.d.ts.map +1 -1
  33. package/dist/types/src/ma-v2/account/common/modularAccountV2Base.d.ts +40 -0
  34. package/dist/types/src/ma-v2/account/common/modularAccountV2Base.d.ts.map +1 -0
  35. package/dist/types/src/ma-v2/account/modularAccountV2.d.ts +17 -0
  36. package/dist/types/src/ma-v2/account/modularAccountV2.d.ts.map +1 -0
  37. package/dist/types/src/ma-v2/account/nativeSMASigner.d.ts +1 -1
  38. package/dist/types/src/ma-v2/actions/install-validation/installValidation.d.ts +11 -9
  39. package/dist/types/src/ma-v2/actions/install-validation/installValidation.d.ts.map +1 -1
  40. package/dist/types/src/ma-v2/client/client.d.ts +7 -6
  41. package/dist/types/src/ma-v2/client/client.d.ts.map +1 -1
  42. package/dist/types/src/ma-v2/index.d.ts +0 -4
  43. package/dist/types/src/ma-v2/index.d.ts.map +1 -1
  44. package/dist/types/src/ma-v2/modules/allowlist-module/module.d.ts +14 -0
  45. package/dist/types/src/ma-v2/modules/allowlist-module/module.d.ts.map +1 -1
  46. package/dist/types/src/ma-v2/modules/single-signer-validation/signer.d.ts +1 -1
  47. package/dist/types/src/ma-v2/modules/time-range-module/module.d.ts +10 -1
  48. package/dist/types/src/ma-v2/modules/time-range-module/module.d.ts.map +1 -1
  49. package/package.json +6 -6
  50. package/src/index.ts +7 -0
  51. package/src/ma-v2/account/{semiModularAccountV2.ts → common/modularAccountV2Base.ts} +62 -105
  52. package/src/ma-v2/account/modularAccountV2.ts +193 -0
  53. package/src/ma-v2/account/nativeSMASigner.ts +1 -1
  54. package/src/ma-v2/actions/install-validation/installValidation.ts +75 -36
  55. package/src/ma-v2/client/client.ts +54 -34
  56. package/src/ma-v2/index.ts +0 -5
  57. package/src/ma-v2/modules/allowlist-module/module.ts +29 -0
  58. package/src/ma-v2/modules/single-signer-validation/signer.ts +1 -1
  59. package/src/ma-v2/modules/time-range-module/module.ts +34 -1
  60. package/dist/esm/src/ma-v2/account/semiModularAccountV2.d.ts +0 -41
  61. package/dist/esm/src/ma-v2/account/semiModularAccountV2.js.map +0 -1
  62. package/dist/types/src/ma-v2/account/semiModularAccountV2.d.ts +0 -42
  63. package/dist/types/src/ma-v2/account/semiModularAccountV2.d.ts.map +0 -1
@@ -51,3 +51,8 @@ export { SessionKeySigner } from "./msca/plugins/session-key/signer.js";
51
51
  export { buildSessionKeysToRemoveStruct } from "./msca/plugins/session-key/utils.js";
52
52
  export type * from "./msca/plugins/types.js";
53
53
  export { getDefaultMultiOwnerModularAccountFactoryAddress, getDefaultMultisigModularAccountFactoryAddress, getMAInitializationData, getMSCAUpgradeToData, } from "./msca/utils.js";
54
+ export type * from "./ma-v2/account/modularAccountV2.js";
55
+ export type * from "./ma-v2/account/common/modularAccountV2Base.js";
56
+ export { createModularAccountV2 } from "./ma-v2/account/modularAccountV2.js";
57
+ export type * from "./ma-v2/client/client.js";
58
+ export { createModularAccountV2Client } from "./ma-v2/client/client.js";
@@ -39,4 +39,6 @@ export { SessionKeyPlugin, SessionKeyPluginAbi, SessionKeyPluginExecutionFunctio
39
39
  export { SessionKeySigner } from "./msca/plugins/session-key/signer.js";
40
40
  export { buildSessionKeysToRemoveStruct } from "./msca/plugins/session-key/utils.js";
41
41
  export { getDefaultMultiOwnerModularAccountFactoryAddress, getDefaultMultisigModularAccountFactoryAddress, getMAInitializationData, getMSCAUpgradeToData, } from "./msca/utils.js";
42
+ export { createModularAccountV2 } from "./ma-v2/account/modularAccountV2.js";
43
+ export { createModularAccountV2Client } from "./ma-v2/client/client.js";
42
44
  //# sourceMappingURL=index.js.map
@@ -1 +1 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AuB,EACvB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC","sourcesContent":["// Add you exports here, make sure to export types separately from impls and use the `type` keyword when exporting them\n// Don't use wildcard exports, instead use named exports\n\n//light-account exports\nexport type * from \"./light-account/accounts/account.js\";\nexport { createLightAccount } from \"./light-account/accounts/account.js\";\nexport { transferOwnership as transferLightAccountOwnership } from \"./light-account/actions/transferOwnership.js\";\nexport {\n createLightAccountAlchemyClient,\n type AlchemyLightAccountClientConfig,\n} from \"./light-account/clients/alchemyClient.js\";\nexport { createLightAccountClient } from \"./light-account/clients/client.js\";\nexport {\n createMultiOwnerLightAccountAlchemyClient,\n type AlchemyMultiOwnerLightAccountClientConfig,\n} from \"./light-account/clients/multiOwnerAlchemyClient.js\";\nexport type * from \"./light-account/decorators/lightAccount.js\";\nexport { lightAccountClientActions } from \"./light-account/decorators/lightAccount.js\";\nexport type * from \"./light-account/types.js\";\n\nexport {\n AccountVersionRegistry,\n LightAccountUnsupported1271Factories,\n LightAccountUnsupported1271Impls,\n defaultLightAccountVersion,\n getDefaultLightAccountFactoryAddress,\n getDefaultMultiOwnerLightAccountFactoryAddress,\n getLightAccountVersionForAccount,\n} from \"./light-account/utils.js\";\n\n//multi-owner-light-account exports\nexport type * from \"./light-account/accounts/multiOwner.js\";\nexport { createMultiOwnerLightAccount } from \"./light-account/accounts/multiOwner.js\";\nexport { updateOwners as updateMultiOwnerLightAccountOwners } from \"./light-account/actions/updateOwners.js\";\nexport { createMultiOwnerLightAccountClient } from \"./light-account/clients/multiOwnerLightAccount.js\";\nexport type * from \"./light-account/decorators/multiOwnerLightAccount.js\";\nexport { multiOwnerLightAccountClientActions } from \"./light-account/decorators/multiOwnerLightAccount.js\";\n\n// msca exports\nexport { IAccountLoupeAbi } from \"./msca/abis/IAccountLoupe.js\";\nexport { IPluginAbi } from \"./msca/abis/IPlugin.js\";\nexport { IPluginManagerAbi } from \"./msca/abis/IPluginManager.js\";\nexport { IStandardExecutorAbi } from \"./msca/abis/IStandardExecutor.js\";\nexport { MultiOwnerModularAccountFactoryAbi } from \"./msca/abis/MultiOwnerModularAccountFactory.js\";\nexport { MultisigModularAccountFactoryAbi } from \"./msca/abis/MultisigModularAccountFactory.js\";\nexport { UpgradeableModularAccountAbi } from \"./msca/abis/UpgradeableModularAccount.js\";\nexport type * from \"./msca/account-loupe/decorator.js\";\nexport { accountLoupeActions } from \"./msca/account-loupe/decorator.js\";\nexport type * from \"./msca/account-loupe/types.js\";\nexport type * from \"./msca/account/multiOwnerAccount.js\";\nexport { createMultiOwnerModularAccount } from \"./msca/account/multiOwnerAccount.js\";\nexport type * from \"./msca/account/multisigAccount.js\";\nexport { createMultisigModularAccount } from \"./msca/account/multisigAccount.js\";\nexport { standardExecutor } from \"./msca/account/standardExecutor.js\";\nexport {\n createModularAccountAlchemyClient,\n type AlchemyModularAccountClientConfig,\n} from \"./msca/client/alchemyClient.js\";\nexport {\n createMultiOwnerModularAccountClient,\n createMultisigModularAccountClient,\n} from \"./msca/client/client.js\";\nexport {\n createMultisigAccountAlchemyClient,\n type AlchemyMultisigAccountClientConfig,\n} from \"./msca/client/multiSigAlchemyClient.js\";\nexport {\n InvalidAggregatedSignatureError,\n InvalidContextSignatureError,\n MultisigAccountExpectedError,\n MultisigMissingSignatureError,\n} from \"./msca/errors.js\";\nexport type * from \"./msca/plugin-manager/decorator.js\";\nexport { pluginManagerActions } from \"./msca/plugin-manager/decorator.js\";\nexport { installPlugin } from \"./msca/plugin-manager/installPlugin.js\";\nexport { multiOwnerPluginActions } from \"./msca/plugins/multi-owner/extension.js\";\nexport type * from \"./msca/plugins/multi-owner/index.js\";\nexport {\n MultiOwnerPlugin,\n MultiOwnerPluginAbi,\n MultiOwnerPluginExecutionFunctionAbi,\n} from \"./msca/plugins/multi-owner/plugin.js\";\nexport type * from \"./msca/plugins/multisig/index.js\";\nexport {\n MultisigPlugin,\n MultisigPluginAbi,\n MultisigPluginExecutionFunctionAbi,\n multisigPluginActions,\n multisigSignatureMiddleware,\n} from \"./msca/plugins/multisig/index.js\";\nexport {\n combineSignatures,\n formatSignatures,\n getSignerType,\n splitAggregatedSignature,\n} from \"./msca/plugins/multisig/utils/index.js\";\nexport { sessionKeyPluginActions } from \"./msca/plugins/session-key/extension.js\";\nexport type * from \"./msca/plugins/session-key/index.js\";\nexport type * from \"./msca/plugins/session-key/permissions.js\";\nexport {\n SessionKeyAccessListType,\n SessionKeyPermissionsBuilder,\n} from \"./msca/plugins/session-key/permissions.js\";\nexport {\n SessionKeyPlugin,\n SessionKeyPluginAbi,\n SessionKeyPluginExecutionFunctionAbi,\n} from \"./msca/plugins/session-key/plugin.js\";\nexport { SessionKeySigner } from \"./msca/plugins/session-key/signer.js\";\nexport { buildSessionKeysToRemoveStruct } from \"./msca/plugins/session-key/utils.js\";\nexport type * from \"./msca/plugins/types.js\";\nexport {\n getDefaultMultiOwnerModularAccountFactoryAddress,\n getDefaultMultisigModularAccountFactoryAddress,\n getMAInitializationData,\n getMSCAUpgradeToData,\n} from \"./msca/utils.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,uHAAuH;AACvH,wDAAwD;AAIxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,iBAAiB,IAAI,6BAA6B,EAAE,MAAM,8CAA8C,CAAC;AAClH,OAAO,EACL,+BAA+B,GAEhC,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EACL,yCAAyC,GAE1C,MAAM,oDAAoD,CAAC;AAE5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAGvF,OAAO,EACL,sBAAsB,EACtB,oCAAoC,EACpC,gCAAgC,EAChC,0BAA0B,EAC1B,oCAAoC,EACpC,8CAA8C,EAC9C,gCAAgC,GACjC,MAAM,0BAA0B,CAAC;AAIlC,OAAO,EAAE,4BAA4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AAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,oCAAoC,GACrC,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,kCAAkC,EAClC,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,wBAAwB,GACzB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAGlF,OAAO,EACL,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,oCAAoC,GACrC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAErF,OAAO,EACL,gDAAgD,EAChD,8CAA8C,EAC9C,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAKzB,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAE7E,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC","sourcesContent":["// Add you exports here, make sure to export types separately from impls and use the `type` keyword when exporting them\n// Don't use wildcard exports, instead use named exports\n\n//light-account exports\nexport type * from \"./light-account/accounts/account.js\";\nexport { createLightAccount } from \"./light-account/accounts/account.js\";\nexport { transferOwnership as transferLightAccountOwnership } from \"./light-account/actions/transferOwnership.js\";\nexport {\n createLightAccountAlchemyClient,\n type AlchemyLightAccountClientConfig,\n} from \"./light-account/clients/alchemyClient.js\";\nexport { createLightAccountClient } from \"./light-account/clients/client.js\";\nexport {\n createMultiOwnerLightAccountAlchemyClient,\n type AlchemyMultiOwnerLightAccountClientConfig,\n} from \"./light-account/clients/multiOwnerAlchemyClient.js\";\nexport type * from \"./light-account/decorators/lightAccount.js\";\nexport { lightAccountClientActions } from \"./light-account/decorators/lightAccount.js\";\nexport type * from \"./light-account/types.js\";\n\nexport {\n AccountVersionRegistry,\n LightAccountUnsupported1271Factories,\n LightAccountUnsupported1271Impls,\n defaultLightAccountVersion,\n getDefaultLightAccountFactoryAddress,\n getDefaultMultiOwnerLightAccountFactoryAddress,\n getLightAccountVersionForAccount,\n} from \"./light-account/utils.js\";\n\n//multi-owner-light-account exports\nexport type * from \"./light-account/accounts/multiOwner.js\";\nexport { createMultiOwnerLightAccount } from \"./light-account/accounts/multiOwner.js\";\nexport { updateOwners as updateMultiOwnerLightAccountOwners } from \"./light-account/actions/updateOwners.js\";\nexport { createMultiOwnerLightAccountClient } from \"./light-account/clients/multiOwnerLightAccount.js\";\nexport type * from \"./light-account/decorators/multiOwnerLightAccount.js\";\nexport { multiOwnerLightAccountClientActions } from \"./light-account/decorators/multiOwnerLightAccount.js\";\n\n// msca exports\nexport { IAccountLoupeAbi } from \"./msca/abis/IAccountLoupe.js\";\nexport { IPluginAbi } from \"./msca/abis/IPlugin.js\";\nexport { IPluginManagerAbi } from \"./msca/abis/IPluginManager.js\";\nexport { IStandardExecutorAbi } from \"./msca/abis/IStandardExecutor.js\";\nexport { MultiOwnerModularAccountFactoryAbi } from \"./msca/abis/MultiOwnerModularAccountFactory.js\";\nexport { MultisigModularAccountFactoryAbi } from \"./msca/abis/MultisigModularAccountFactory.js\";\nexport { UpgradeableModularAccountAbi } from \"./msca/abis/UpgradeableModularAccount.js\";\nexport type * from \"./msca/account-loupe/decorator.js\";\nexport { accountLoupeActions } from \"./msca/account-loupe/decorator.js\";\nexport type * from \"./msca/account-loupe/types.js\";\nexport type * from \"./msca/account/multiOwnerAccount.js\";\nexport { createMultiOwnerModularAccount } from \"./msca/account/multiOwnerAccount.js\";\nexport type * from \"./msca/account/multisigAccount.js\";\nexport { createMultisigModularAccount } from \"./msca/account/multisigAccount.js\";\nexport { standardExecutor } from \"./msca/account/standardExecutor.js\";\nexport {\n createModularAccountAlchemyClient,\n type AlchemyModularAccountClientConfig,\n} from \"./msca/client/alchemyClient.js\";\nexport {\n createMultiOwnerModularAccountClient,\n createMultisigModularAccountClient,\n} from \"./msca/client/client.js\";\nexport {\n createMultisigAccountAlchemyClient,\n type AlchemyMultisigAccountClientConfig,\n} from \"./msca/client/multiSigAlchemyClient.js\";\nexport {\n InvalidAggregatedSignatureError,\n InvalidContextSignatureError,\n MultisigAccountExpectedError,\n MultisigMissingSignatureError,\n} from \"./msca/errors.js\";\nexport type * from \"./msca/plugin-manager/decorator.js\";\nexport { pluginManagerActions } from \"./msca/plugin-manager/decorator.js\";\nexport { installPlugin } from \"./msca/plugin-manager/installPlugin.js\";\nexport { multiOwnerPluginActions } from \"./msca/plugins/multi-owner/extension.js\";\nexport type * from \"./msca/plugins/multi-owner/index.js\";\nexport {\n MultiOwnerPlugin,\n MultiOwnerPluginAbi,\n MultiOwnerPluginExecutionFunctionAbi,\n} from \"./msca/plugins/multi-owner/plugin.js\";\nexport type * from \"./msca/plugins/multisig/index.js\";\nexport {\n MultisigPlugin,\n MultisigPluginAbi,\n MultisigPluginExecutionFunctionAbi,\n multisigPluginActions,\n multisigSignatureMiddleware,\n} from \"./msca/plugins/multisig/index.js\";\nexport {\n combineSignatures,\n formatSignatures,\n getSignerType,\n splitAggregatedSignature,\n} from \"./msca/plugins/multisig/utils/index.js\";\nexport { sessionKeyPluginActions } from \"./msca/plugins/session-key/extension.js\";\nexport type * from \"./msca/plugins/session-key/index.js\";\nexport type * from \"./msca/plugins/session-key/permissions.js\";\nexport {\n SessionKeyAccessListType,\n SessionKeyPermissionsBuilder,\n} from \"./msca/plugins/session-key/permissions.js\";\nexport {\n SessionKeyPlugin,\n SessionKeyPluginAbi,\n SessionKeyPluginExecutionFunctionAbi,\n} from \"./msca/plugins/session-key/plugin.js\";\nexport { SessionKeySigner } from \"./msca/plugins/session-key/signer.js\";\nexport { buildSessionKeysToRemoveStruct } from \"./msca/plugins/session-key/utils.js\";\nexport type * from \"./msca/plugins/types.js\";\nexport {\n getDefaultMultiOwnerModularAccountFactoryAddress,\n getDefaultMultisigModularAccountFactoryAddress,\n getMAInitializationData,\n getMSCAUpgradeToData,\n} from \"./msca/utils.js\";\n\n// ma v2 types\nexport type * from \"./ma-v2/account/modularAccountV2.js\";\nexport type * from \"./ma-v2/account/common/modularAccountV2Base.js\";\nexport { createModularAccountV2 } from \"./ma-v2/account/modularAccountV2.js\";\nexport type * from \"./ma-v2/client/client.js\";\nexport { createModularAccountV2Client } from \"./ma-v2/client/client.js\";\n"]}
@@ -0,0 +1,39 @@
1
+ import { type SmartAccountSigner, type SmartContractAccountWithSigner, type ToSmartContractAccountParams } from "@aa-sdk/core";
2
+ import { type Hex, type Address, type Chain, type Transport } from "viem";
3
+ export declare const executeUserOpSelector: Hex;
4
+ export type SignerEntity = {
5
+ isGlobalValidation: boolean;
6
+ entityId: number;
7
+ };
8
+ export type ExecutionDataView = {
9
+ module: Address;
10
+ skipRuntimeValidation: boolean;
11
+ allowGlobalValidation: boolean;
12
+ executionHooks: readonly Hex[];
13
+ };
14
+ export type ValidationDataView = {
15
+ validationHooks: readonly Hex[];
16
+ executionHooks: readonly Hex[];
17
+ selectors: readonly Hex[];
18
+ validationFlags: number;
19
+ };
20
+ export type ValidationDataParams = {
21
+ validationModuleAddress: Address;
22
+ entityId?: never;
23
+ } | {
24
+ validationModuleAddress?: never;
25
+ entityId: number;
26
+ };
27
+ export type ModularAccountV2<TSigner extends SmartAccountSigner = SmartAccountSigner> = SmartContractAccountWithSigner<"ModularAccountV2", TSigner, "0.7.0"> & {
28
+ signerEntity: SignerEntity;
29
+ getExecutionData: (selector: Hex) => Promise<ExecutionDataView>;
30
+ getValidationData: (args: ValidationDataParams) => Promise<ValidationDataView>;
31
+ encodeCallData: (callData: Hex) => Promise<Hex>;
32
+ };
33
+ export type CreateMAV2BaseParams<TSigner extends SmartAccountSigner = SmartAccountSigner, TTransport extends Transport = Transport> = Omit<ToSmartContractAccountParams<"ModularAccountV2", TTransport, Chain, "0.7.0">, "encodeExecute" | "encodeBatchExecute" | "getNonce" | "signMessage" | "signTypedData" | "getDummySignature"> & {
34
+ signer: TSigner;
35
+ signerEntity?: SignerEntity;
36
+ accountAddress: Address;
37
+ };
38
+ export type CreateMAV2BaseReturnType<TSigner extends SmartAccountSigner = SmartAccountSigner> = Promise<ModularAccountV2<TSigner>>;
39
+ export declare function createMAv2Base<TSigner extends SmartAccountSigner = SmartAccountSigner>(config: CreateMAV2BaseParams<TSigner>): CreateMAV2BaseReturnType<TSigner>;
@@ -1,24 +1,16 @@
1
- import { createBundlerClient, getEntryPoint, toSmartContractAccount, InvalidEntityIdError, InvalidNonceKeyError, getAccountAddress, } from "@aa-sdk/core";
2
- import { concatHex, encodeFunctionData, getContract, maxUint32, maxUint152, zeroAddress, } from "viem";
3
- import { accountFactoryAbi } from "../abis/accountFactoryAbi.js";
4
- import { getDefaultMAV2FactoryAddress, DEFAULT_OWNER_ENTITY_ID, } from "../utils.js";
5
- import { singleSignerMessageSigner } from "../modules/single-signer-validation/signer.js";
6
- import { nativeSMASigner } from "./nativeSMASigner.js";
7
- import { modularAccountAbi } from "../abis/modularAccountAbi.js";
8
- import { serializeModuleEntity } from "../actions/common/utils.js";
9
- const executeUserOpSelector = "0x8DD7712F";
10
- /**
11
- * Creates an SMAV2 account using defined parameters including chain, signer, salt, factory address, and more.
12
- * Handles account initialization code, nonce generation, transaction encoding, and more to construct a modular account with optional validation hooks.
13
- *
14
- * @param {CreateSMAV2AccountParams} config Configuration parameters for creating an SMAV2 account. Includes chain details, signer, salt, factory address, and more.
15
- * @returns {Promise<MAV2Account>} A promise that resolves to an `MAV2Account` providing methods for nonce retrieval, transaction execution, and more.
16
- */
17
- export async function createSMAV2Account(config) {
18
- const { transport, chain, signer, salt = 0n, factoryAddress = getDefaultMAV2FactoryAddress(chain), initCode, initialOwner, accountAddress, entryPoint = getEntryPoint(chain, { version: "0.7.0" }), signerEntity = {
1
+ import { createBundlerClient, getEntryPoint, InvalidEntityIdError, InvalidNonceKeyError, toSmartContractAccount, } from "@aa-sdk/core";
2
+ import { DEFAULT_OWNER_ENTITY_ID } from "../../utils.js";
3
+ import { encodeFunctionData, maxUint32, zeroAddress, getContract, concatHex, maxUint152, } from "viem";
4
+ import { modularAccountAbi } from "../../abis/modularAccountAbi.js";
5
+ import { serializeModuleEntity } from "../../actions/common/utils.js";
6
+ import { nativeSMASigner } from "../nativeSMASigner.js";
7
+ import { singleSignerMessageSigner } from "../../modules/single-signer-validation/signer.js";
8
+ export const executeUserOpSelector = "0x8DD7712F";
9
+ export async function createMAv2Base(config) {
10
+ const { transport, chain, signer, entryPoint = getEntryPoint(chain, { version: "0.7.0" }), signerEntity = {
19
11
  isGlobalValidation: true,
20
12
  entityId: DEFAULT_OWNER_ENTITY_ID,
21
- }, signerEntity: { isGlobalValidation = true, entityId = DEFAULT_OWNER_ENTITY_ID, } = {}, } = config;
13
+ }, signerEntity: { isGlobalValidation = true, entityId = DEFAULT_OWNER_ENTITY_ID, } = {}, accountAddress, ...remainingToSmartContractAccountParams } = config;
22
14
  if (entityId > Number(maxUint32)) {
23
15
  throw new InvalidEntityIdError(entityId);
24
16
  }
@@ -26,21 +18,6 @@ export async function createSMAV2Account(config) {
26
18
  transport,
27
19
  chain,
28
20
  });
29
- const getAccountInitCode = async () => {
30
- if (initCode) {
31
- return initCode;
32
- }
33
- // If an initial owner is not provided, use the signer's address
34
- const ownerAddress = initialOwner ?? (await signer.getAddress());
35
- return concatHex([
36
- factoryAddress,
37
- encodeFunctionData({
38
- abi: accountFactoryAbi,
39
- functionName: "createSemiModularAccount",
40
- args: [ownerAddress, salt],
41
- }),
42
- ]);
43
- };
44
21
  const encodeExecute = async ({ target, data, value, }) => await encodeCallData(encodeFunctionData({
45
22
  abi: modularAccountAbi,
46
23
  functionName: "execute",
@@ -57,27 +34,9 @@ export async function createSMAV2Account(config) {
57
34
  })),
58
35
  ],
59
36
  }));
60
- const _accountAddress = await getAccountAddress({
61
- client,
62
- entryPoint,
63
- accountAddress,
64
- getAccountInitCode,
65
- });
66
- const baseAccount = await toSmartContractAccount({
67
- transport,
68
- chain,
69
- entryPoint,
70
- accountAddress: _accountAddress,
71
- source: `MAV2Account`,
72
- encodeExecute,
73
- encodeBatchExecute,
74
- getAccountInitCode,
75
- ...(entityId === DEFAULT_OWNER_ENTITY_ID
76
- ? nativeSMASigner(signer, chain, _accountAddress)
77
- : singleSignerMessageSigner(signer, chain, _accountAddress, entityId)),
78
- });
37
+ const isAccountDeployed = async () => !!(await client.getCode({ address: accountAddress }));
79
38
  // TODO: add deferred action flag
80
- const getAccountNonce = async (nonceKey = 0n) => {
39
+ const getNonce = async (nonceKey = 0n) => {
81
40
  if (nonceKey > maxUint152) {
82
41
  throw new InvalidNonceKeyError(nonceKey);
83
42
  }
@@ -87,20 +46,20 @@ export async function createSMAV2Account(config) {
87
46
  client,
88
47
  });
89
48
  const fullNonceKey = (nonceKey << 40n) +
90
- BigInt(entityId << 8) +
49
+ (BigInt(entityId) << 8n) +
91
50
  (isGlobalValidation ? 1n : 0n);
92
51
  return entryPointContract.read.getNonce([
93
- _accountAddress,
52
+ accountAddress,
94
53
  fullNonceKey,
95
54
  ]);
96
55
  };
97
56
  const accountContract = getContract({
98
- address: _accountAddress,
57
+ address: accountAddress,
99
58
  abi: modularAccountAbi,
100
59
  client,
101
60
  });
102
61
  const getExecutionData = async (selector) => {
103
- if (!(await baseAccount.isAccountDeployed())) {
62
+ if (!(await isAccountDeployed())) {
104
63
  return {
105
64
  module: zeroAddress,
106
65
  skipRuntimeValidation: false,
@@ -111,7 +70,7 @@ export async function createSMAV2Account(config) {
111
70
  return await accountContract.read.getExecutionData([selector]);
112
71
  };
113
72
  const getValidationData = async (args) => {
114
- if (!(await baseAccount.isAccountDeployed())) {
73
+ if (!(await isAccountDeployed())) {
115
74
  return {
116
75
  validationHooks: [],
117
76
  executionHooks: [],
@@ -135,9 +94,21 @@ export async function createSMAV2Account(config) {
135
94
  ? concatHex([executeUserOpSelector, callData])
136
95
  : callData;
137
96
  };
97
+ const baseAccount = await toSmartContractAccount({
98
+ ...remainingToSmartContractAccountParams,
99
+ transport,
100
+ chain,
101
+ entryPoint,
102
+ accountAddress,
103
+ encodeExecute,
104
+ encodeBatchExecute,
105
+ getNonce,
106
+ ...(entityId === DEFAULT_OWNER_ENTITY_ID
107
+ ? nativeSMASigner(signer, chain, accountAddress)
108
+ : singleSignerMessageSigner(signer, chain, accountAddress, entityId)),
109
+ });
138
110
  return {
139
111
  ...baseAccount,
140
- getAccountNonce,
141
112
  getSigner: () => signer,
142
113
  signerEntity,
143
114
  getExecutionData,
@@ -145,4 +116,4 @@ export async function createSMAV2Account(config) {
145
116
  encodeCallData,
146
117
  };
147
118
  }
148
- //# sourceMappingURL=semiModularAccountV2.js.map
119
+ //# sourceMappingURL=modularAccountV2Base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modularAccountV2Base.js","sourceRoot":"","sources":["../../../../../../src/ma-v2/account/common/modularAccountV2Base.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,GAKvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAKL,kBAAkB,EAClB,SAAS,EACT,WAAW,EACX,WAAW,EACX,SAAS,EACT,UAAU,GACX,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,kDAAkD,CAAC;AAE7F,MAAM,CAAC,MAAM,qBAAqB,GAAQ,YAAY,CAAC;AAgEvD,MAAM,CAAC,KAAK,UAAU,cAAc,CAElC,MAAqC;IACr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AAC,CAAC;IAEH,OAAO;QACL,GAAG,WAAW;QACd,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM;QACvB,YAAY;QACZ,gBAAgB;QAChB,iBAAiB;QACjB,cAAc;KACf,CAAC;AACJ,CAAC","sourcesContent":["import {\n createBundlerClient,\n getEntryPoint,\n InvalidEntityIdError,\n InvalidNonceKeyError,\n toSmartContractAccount,\n type AccountOp,\n type SmartAccountSigner,\n type SmartContractAccountWithSigner,\n type ToSmartContractAccountParams,\n} from \"@aa-sdk/core\";\nimport { DEFAULT_OWNER_ENTITY_ID } from \"../../utils.js\";\nimport {\n type Hex,\n type Address,\n type Chain,\n type Transport,\n encodeFunctionData,\n maxUint32,\n zeroAddress,\n getContract,\n concatHex,\n maxUint152,\n} from \"viem\";\nimport { modularAccountAbi } from \"../../abis/modularAccountAbi.js\";\nimport { serializeModuleEntity } from \"../../actions/common/utils.js\";\nimport { nativeSMASigner } from \"../nativeSMASigner.js\";\nimport { singleSignerMessageSigner } from \"../../modules/single-signer-validation/signer.js\";\n\nexport const executeUserOpSelector: Hex = \"0x8DD7712F\";\n\nexport type SignerEntity = {\n isGlobalValidation: boolean;\n entityId: number;\n};\n\nexport type ExecutionDataView = {\n module: Address;\n skipRuntimeValidation: boolean;\n allowGlobalValidation: boolean;\n executionHooks: readonly Hex[];\n};\n\nexport type ValidationDataView = {\n validationHooks: readonly Hex[];\n executionHooks: readonly Hex[];\n selectors: readonly Hex[];\n validationFlags: number;\n};\n\nexport type ValidationDataParams =\n | {\n validationModuleAddress: Address;\n entityId?: never;\n }\n | {\n validationModuleAddress?: never;\n entityId: number;\n };\n\nexport type ModularAccountV2<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = SmartContractAccountWithSigner<\"ModularAccountV2\", TSigner, \"0.7.0\"> & {\n signerEntity: SignerEntity;\n getExecutionData: (selector: Hex) => Promise<ExecutionDataView>;\n getValidationData: (\n args: ValidationDataParams\n ) => Promise<ValidationDataView>;\n encodeCallData: (callData: Hex) => Promise<Hex>;\n};\n\nexport type CreateMAV2BaseParams<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TTransport extends Transport = Transport\n> = Omit<\n ToSmartContractAccountParams<\"ModularAccountV2\", TTransport, Chain, \"0.7.0\">,\n // Implements the following methods required by `toSmartContractAccount`, and passes through any other parameters.\n | \"encodeExecute\"\n | \"encodeBatchExecute\"\n | \"getNonce\"\n | \"signMessage\"\n | \"signTypedData\"\n | \"getDummySignature\"\n> & {\n signer: TSigner;\n signerEntity?: SignerEntity;\n accountAddress: Address;\n};\n\nexport type CreateMAV2BaseReturnType<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = Promise<ModularAccountV2<TSigner>>;\n\nexport async function createMAv2Base<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n>(config: CreateMAV2BaseParams<TSigner>): CreateMAV2BaseReturnType<TSigner> {\n const {\n transport,\n chain,\n signer,\n entryPoint = getEntryPoint(chain, { version: \"0.7.0\" }),\n signerEntity = {\n isGlobalValidation: true,\n entityId: DEFAULT_OWNER_ENTITY_ID,\n },\n signerEntity: {\n isGlobalValidation = true,\n entityId = DEFAULT_OWNER_ENTITY_ID,\n } = {},\n accountAddress,\n ...remainingToSmartContractAccountParams\n } = config;\n\n if (entityId > Number(maxUint32)) {\n throw new InvalidEntityIdError(entityId);\n }\n\n const client = createBundlerClient({\n transport,\n chain,\n });\n\n const encodeExecute: (tx: AccountOp) => Promise<Hex> = async ({\n target,\n data,\n value,\n }) =>\n await encodeCallData(\n encodeFunctionData({\n abi: modularAccountAbi,\n functionName: \"execute\",\n args: [target, value ?? 0n, data],\n })\n );\n\n const encodeBatchExecute: (txs: AccountOp[]) => Promise<Hex> = async (txs) =>\n await encodeCallData(\n encodeFunctionData({\n abi: modularAccountAbi,\n functionName: \"executeBatch\",\n args: [\n txs.map((tx) => ({\n target: tx.target,\n data: tx.data,\n value: tx.value ?? 0n,\n })),\n ],\n })\n );\n\n const isAccountDeployed: () => Promise<boolean> = async () =>\n !!(await client.getCode({ address: accountAddress }));\n // TODO: add deferred action flag\n const getNonce = async (nonceKey: bigint = 0n): Promise<bigint> => {\n if (nonceKey > maxUint152) {\n throw new InvalidNonceKeyError(nonceKey);\n }\n\n const entryPointContract = getContract({\n address: entryPoint.address,\n abi: entryPoint.abi,\n client,\n });\n\n const fullNonceKey: bigint =\n (nonceKey << 40n) +\n (BigInt(entityId) << 8n) +\n (isGlobalValidation ? 1n : 0n);\n\n return entryPointContract.read.getNonce([\n accountAddress,\n fullNonceKey,\n ]) as Promise<bigint>;\n };\n\n const accountContract = getContract({\n address: accountAddress,\n abi: modularAccountAbi,\n client,\n });\n\n const getExecutionData = async (selector: Hex) => {\n if (!(await isAccountDeployed())) {\n return {\n module: zeroAddress,\n skipRuntimeValidation: false,\n allowGlobalValidation: false,\n executionHooks: [],\n };\n }\n\n return await accountContract.read.getExecutionData([selector]);\n };\n\n const getValidationData = async (args: ValidationDataParams) => {\n if (!(await isAccountDeployed())) {\n return {\n validationHooks: [],\n executionHooks: [],\n selectors: [],\n validationFlags: 0,\n };\n }\n\n const { validationModuleAddress, entityId } = args;\n return await accountContract.read.getValidationData([\n serializeModuleEntity({\n moduleAddress: validationModuleAddress ?? zeroAddress,\n entityId: entityId ?? Number(maxUint32),\n }),\n ]);\n };\n\n const encodeCallData = async (callData: Hex): Promise<Hex> => {\n const validationData = await getValidationData({\n entityId: Number(entityId),\n });\n\n return validationData.executionHooks.length\n ? concatHex([executeUserOpSelector, callData])\n : callData;\n };\n\n const baseAccount = await toSmartContractAccount({\n ...remainingToSmartContractAccountParams,\n transport,\n chain,\n entryPoint,\n accountAddress,\n encodeExecute,\n encodeBatchExecute,\n getNonce,\n ...(entityId === DEFAULT_OWNER_ENTITY_ID\n ? nativeSMASigner(signer, chain, accountAddress)\n : singleSignerMessageSigner(signer, chain, accountAddress, entityId)),\n });\n\n return {\n ...baseAccount,\n getSigner: () => signer,\n signerEntity,\n getExecutionData,\n getValidationData,\n encodeCallData,\n };\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import type { EntryPointDef, SmartAccountSigner, ToSmartContractAccountParams } from "@aa-sdk/core";
2
+ import { type Address, type Chain, type Hex, type Transport } from "viem";
3
+ import { type SignerEntity, type ModularAccountV2 } from "./common/modularAccountV2Base.js";
4
+ export type CreateModularAccountV2Params<TTransport extends Transport = Transport, TSigner extends SmartAccountSigner = SmartAccountSigner> = (Pick<ToSmartContractAccountParams<"ModularAccountV2", TTransport, Chain, "0.7.0">, "transport" | "chain" | "accountAddress"> & {
5
+ signer: TSigner;
6
+ entryPoint?: EntryPointDef<"0.7.0", Chain>;
7
+ signerEntity?: SignerEntity;
8
+ }) & ({
9
+ mode?: "default";
10
+ salt?: bigint;
11
+ factoryAddress?: Address;
12
+ initCode?: Hex;
13
+ } | {
14
+ mode: "7702";
15
+ });
16
+ export declare function createModularAccountV2<TTransport extends Transport = Transport, TSigner extends SmartAccountSigner = SmartAccountSigner>(config: CreateModularAccountV2Params<TTransport, TSigner>): Promise<ModularAccountV2<TSigner>>;
@@ -0,0 +1,113 @@
1
+ import { createBundlerClient, getEntryPoint, getAccountAddress, EntityIdOverrideError, InvalidModularAccountV2Mode, } from "@aa-sdk/core";
2
+ import { concatHex, encodeFunctionData, } from "viem";
3
+ import { accountFactoryAbi } from "../abis/accountFactoryAbi.js";
4
+ import { getDefaultMAV2FactoryAddress } from "../utils.js";
5
+ import { createMAv2Base, } from "./common/modularAccountV2Base.js";
6
+ import { DEFAULT_OWNER_ENTITY_ID } from "../utils.js";
7
+ /**
8
+ * Creates a ModularAccount V2 account, with the mode depending on the provided "mode" field.
9
+ * Possible modes include: "default", which is SMA Bytecode, and "7702", which is SMA 7702.
10
+ * Handles nonce generation, transaction encoding, and mode variant-specific behavior like initcode construction.
11
+ *
12
+ * @example
13
+ * ```ts twoslash
14
+ * import { createModularAccountV2 } from "@account-kit/smart-contracts";
15
+ * import { LocalAccountSigner } from "@aa-sdk/core";
16
+ * import { alchemy, sepolia } from "@account-kit/infra";
17
+ *
18
+ * const MNEMONIC = "...";
19
+ * const RPC_URL = "...";
20
+ *
21
+ * const signer = LocalAccountSigner.mnemonicToAccountSigner(MNEMONIC);
22
+ *
23
+ * const chain = sepolia;
24
+ *
25
+ * const transport = alchemy({ rpcUrl: RPC_URL });
26
+ *
27
+ *
28
+ * const modularAccountV2 = await createModularAccountV2({
29
+ * mode: "default", // or "7702"
30
+ * chain,
31
+ * signer,
32
+ * transport,
33
+ * });
34
+ * ```
35
+ *
36
+ * @param {CreateModularAccountV2Params} config Configuration parameters for creating a Modular Account V2.
37
+ * @returns {Promise<ModularAccountV2>} A promise that resolves to an `ModularAccountV2` providing methods for nonce retrieval, transaction execution, and more.
38
+ */
39
+ export async function createModularAccountV2(config) {
40
+ const { transport, chain, signer, accountAddress: _accountAddress, entryPoint = getEntryPoint(chain, { version: "0.7.0" }), signerEntity = {
41
+ isGlobalValidation: true,
42
+ entityId: DEFAULT_OWNER_ENTITY_ID,
43
+ }, signerEntity: { entityId = DEFAULT_OWNER_ENTITY_ID } = {}, } = config;
44
+ const client = createBundlerClient({
45
+ transport,
46
+ chain,
47
+ });
48
+ const accountFunctions = await (async () => {
49
+ switch (config.mode) {
50
+ case "7702": {
51
+ const getAccountInitCode = async () => {
52
+ return "0x";
53
+ };
54
+ const signerAddress = await signer.getAddress();
55
+ const accountAddress = _accountAddress ?? signerAddress;
56
+ if (entityId === DEFAULT_OWNER_ENTITY_ID &&
57
+ signerAddress !== accountAddress) {
58
+ throw new EntityIdOverrideError();
59
+ }
60
+ const implementation = "0x69007702764179f14F51cdce752f4f775d74E139";
61
+ const getImplementationAddress = async () => implementation;
62
+ return {
63
+ getAccountInitCode,
64
+ accountAddress,
65
+ getImplementationAddress,
66
+ };
67
+ }
68
+ case "default":
69
+ case undefined: {
70
+ const { salt = 0n, factoryAddress = getDefaultMAV2FactoryAddress(chain), initCode, } = config;
71
+ const getAccountInitCode = async () => {
72
+ if (initCode) {
73
+ return initCode;
74
+ }
75
+ return concatHex([
76
+ factoryAddress,
77
+ encodeFunctionData({
78
+ abi: accountFactoryAbi,
79
+ functionName: "createSemiModularAccount",
80
+ args: [await signer.getAddress(), salt],
81
+ }),
82
+ ]);
83
+ };
84
+ const accountAddress = await getAccountAddress({
85
+ client,
86
+ entryPoint,
87
+ accountAddress: _accountAddress,
88
+ getAccountInitCode,
89
+ });
90
+ return {
91
+ getAccountInitCode,
92
+ accountAddress,
93
+ };
94
+ }
95
+ default:
96
+ assertNever(config);
97
+ }
98
+ })();
99
+ return createMAv2Base({
100
+ source: "ModularAccountV2",
101
+ transport,
102
+ chain,
103
+ signer,
104
+ entryPoint,
105
+ signerEntity,
106
+ ...accountFunctions,
107
+ });
108
+ }
109
+ // If we add more valid modes, the switch case branch's mode will no longer be `never`, which will cause a compile time error here and ensure we handle the new type.
110
+ function assertNever(_valid) {
111
+ throw new InvalidModularAccountV2Mode();
112
+ }
113
+ //# sourceMappingURL=modularAccountV2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modularAccountV2.js","sourceRoot":"","sources":["../../../../../src/ma-v2/account/modularAccountV2.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,SAAS,EACT,kBAAkB,GAKnB,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAGL,cAAc,GACf,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAgCtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,MAAoC;IAEpC,MAAM,EACJ,SAAS,EACT,KAAK,EACL,MAAM,EACN,cAAc,EAA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OAAO,QAAQ,CAAC;oBAClB,CAAC;oBAED,OAAO,SAAS,CAAC;wBACf,cAAc;wBACd,kBAAkB,CAAC;4BACjB,GAAG,EAAE,iBAAiB;4BACtB,YAAY,EAAE,0BAA0B;4BACxC,IAAI,EAAE,CAAC,MAAM,MAAM,CAAC,UAAU,EAAE,EAAE,IAAI,CAAC;yBACxC,CAAC;qBACH,CAAC,CAAC;gBACL,CAAC,CAAC;gBAEF,MAAM,cAAc,GAAG,MAAM,iBAAiB,CAAC;oBAC7C,MAAM;oBACN,UAAU;oBACV,cAAc,EAAE,eAAe;oBAC/B,kBAAkB;iBACnB,CAAC,CAAC;gBAEH,OAAO;oBACL,kBAAkB;oBAClB,cAAc;iBACf,CAAC;YACJ,CAAC;YACD;gBACE,WAAW,CAAC,MAAM,CAAC,CAAC;QACxB,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;IAEL,OAAO,cAAc,CAAC;QACpB,MAAM,EAAE,kBAAkB;QAC1B,SAAS;QACT,KAAK;QACL,MAAM;QACN,UAAU;QACV,YAAY;QACZ,GAAG,gBAAgB;KACpB,CAAC,CAAC;AACL,CAAC;AAED,qKAAqK;AACrK,SAAS,WAAW,CAAC,MAAa;IAChC,MAAM,IAAI,2BAA2B,EAAE,CAAC;AAC1C,CAAC","sourcesContent":["import type {\n EntryPointDef,\n SmartAccountSigner,\n ToSmartContractAccountParams,\n} from \"@aa-sdk/core\";\nimport {\n createBundlerClient,\n getEntryPoint,\n getAccountAddress,\n EntityIdOverrideError,\n InvalidModularAccountV2Mode,\n} from \"@aa-sdk/core\";\nimport {\n concatHex,\n encodeFunctionData,\n type Address,\n type Chain,\n type Hex,\n type Transport,\n} from \"viem\";\nimport { accountFactoryAbi } from \"../abis/accountFactoryAbi.js\";\nimport { getDefaultMAV2FactoryAddress } from \"../utils.js\";\nimport {\n type SignerEntity,\n type ModularAccountV2,\n createMAv2Base,\n} from \"./common/modularAccountV2Base.js\";\nimport { DEFAULT_OWNER_ENTITY_ID } from \"../utils.js\";\n\nexport type CreateModularAccountV2Params<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = (Pick<\n ToSmartContractAccountParams<\"ModularAccountV2\", TTransport, Chain, \"0.7.0\">,\n \"transport\" | \"chain\" | \"accountAddress\"\n> & {\n signer: TSigner;\n entryPoint?: EntryPointDef<\"0.7.0\", Chain>;\n signerEntity?: SignerEntity;\n}) &\n (\n | {\n mode?: \"default\";\n salt?: bigint;\n factoryAddress?: Address;\n initCode?: Hex;\n }\n | {\n mode: \"7702\";\n }\n );\n\nexport async function createModularAccountV2<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n>(\n config: CreateModularAccountV2Params<TTransport, TSigner>\n): Promise<ModularAccountV2<TSigner>>;\n\n/**\n * Creates a ModularAccount V2 account, with the mode depending on the provided \"mode\" field.\n * Possible modes include: \"default\", which is SMA Bytecode, and \"7702\", which is SMA 7702.\n * Handles nonce generation, transaction encoding, and mode variant-specific behavior like initcode construction.\n *\n * @example\n * ```ts twoslash\n * import { createModularAccountV2 } from \"@account-kit/smart-contracts\";\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { alchemy, sepolia } from \"@account-kit/infra\";\n *\n * const MNEMONIC = \"...\";\n * const RPC_URL = \"...\";\n *\n * const signer = LocalAccountSigner.mnemonicToAccountSigner(MNEMONIC);\n *\n * const chain = sepolia;\n *\n * const transport = alchemy({ rpcUrl: RPC_URL });\n *\n *\n * const modularAccountV2 = await createModularAccountV2({\n * mode: \"default\", // or \"7702\"\n * chain,\n * signer,\n * transport,\n * });\n * ```\n *\n * @param {CreateModularAccountV2Params} config Configuration parameters for creating a Modular Account V2.\n * @returns {Promise<ModularAccountV2>} A promise that resolves to an `ModularAccountV2` providing methods for nonce retrieval, transaction execution, and more.\n */\nexport async function createModularAccountV2(\n config: CreateModularAccountV2Params\n): Promise<ModularAccountV2> {\n const {\n transport,\n chain,\n signer,\n accountAddress: _accountAddress,\n entryPoint = getEntryPoint(chain, { version: \"0.7.0\" }),\n signerEntity = {\n isGlobalValidation: true,\n entityId: DEFAULT_OWNER_ENTITY_ID,\n },\n signerEntity: { entityId = DEFAULT_OWNER_ENTITY_ID } = {},\n } = config;\n\n const client = createBundlerClient({\n transport,\n chain,\n });\n\n const accountFunctions = await (async () => {\n switch (config.mode) {\n case \"7702\": {\n const getAccountInitCode = async (): Promise<Hex> => {\n return \"0x\";\n };\n const signerAddress = await signer.getAddress();\n const accountAddress = _accountAddress ?? signerAddress;\n if (\n entityId === DEFAULT_OWNER_ENTITY_ID &&\n signerAddress !== accountAddress\n ) {\n throw new EntityIdOverrideError();\n }\n\n const implementation: Address =\n \"0x69007702764179f14F51cdce752f4f775d74E139\";\n\n const getImplementationAddress = async () => implementation;\n\n return {\n getAccountInitCode,\n accountAddress,\n getImplementationAddress,\n };\n }\n case \"default\":\n case undefined: {\n const {\n salt = 0n,\n factoryAddress = getDefaultMAV2FactoryAddress(chain),\n initCode,\n } = config;\n\n const getAccountInitCode = async () => {\n if (initCode) {\n return initCode;\n }\n\n return concatHex([\n factoryAddress,\n encodeFunctionData({\n abi: accountFactoryAbi,\n functionName: \"createSemiModularAccount\",\n args: [await signer.getAddress(), salt],\n }),\n ]);\n };\n\n const accountAddress = await getAccountAddress({\n client,\n entryPoint,\n accountAddress: _accountAddress,\n getAccountInitCode,\n });\n\n return {\n getAccountInitCode,\n accountAddress,\n };\n }\n default:\n assertNever(config);\n }\n })();\n\n return createMAv2Base({\n source: \"ModularAccountV2\",\n transport,\n chain,\n signer,\n entryPoint,\n signerEntity,\n ...accountFunctions,\n });\n}\n\n// If we add more valid modes, the switch case branch's mode will no longer be `never`, which will cause a compile time error here and ensure we handle the new type.\nfunction assertNever(_valid: never): never {\n throw new InvalidModularAccountV2Mode();\n}\n"]}
@@ -11,7 +11,7 @@ import { type Hex, type SignableMessage, type TypedDataDefinition, type Chain, t
11
11
  *
12
12
  * const MNEMONIC = "...":
13
13
  *
14
- * const account = createSMAV2Account({ config });
14
+ * const account = createModularAccountV2({ config });
15
15
  *
16
16
  * const signer = LocalAccountSigner.mnemonicToAccountSigner(MNEMONIC);
17
17
  *
@@ -11,7 +11,7 @@ import { packUOSignature, pack1271Signature, DEFAULT_OWNER_ENTITY_ID, } from "..
11
11
  *
12
12
  * const MNEMONIC = "...":
13
13
  *
14
- * const account = createSMAV2Account({ config });
14
+ * const account = createModularAccountV2({ config });
15
15
  *
16
16
  * const signer = LocalAccountSigner.mnemonicToAccountSigner(MNEMONIC);
17
17
  *
@@ -1 +1 @@
1
- {"version":3,"file":"nativeSMASigner.js","sourceRoot":"","sources":["../../../../../src/ma-v2/account/nativeSMASigner.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,aAAa,GAOd,MAAM,MAAM,CAAC;AAEd,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,MAA0B,EAC1B,KAAY,EACZ,cAAuB,EACvB,EAAE;IACF,OAAO;QACL,iBAAiB,EAAE,GAAQ,EAAE;YAC3B,MAAM,mBAAmB,GACvB,sIAAsI,CAAC;YAEzI,OAAO,eAAe,CAAC;gBACrB,uBAAuB;gBACvB,mBAAmB,EAAE,mBAAmB;aACzC,CAAC,CAAC;QACL,CAAC;QAED,qBAAqB,EAAE,CAAC,MAAW,EAAgB,EAAE;YACnD,OAAO,MAAM,CAAC,WAAW,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,SAAc,EAAE,EAAE,CACjE,eAAe,CAAC;gBACd,uBAAuB;gBACvB,mBAAmB,EAAE,SAAS;aAC/B,CAAC,CACH,CAAC;QACJ,CAAC;QAED,oFAAoF;QACpF,KAAK,CAAC,WAAW,CAAC,EAAE,OAAO,EAAgC;YACzD,MAAM,IAAI,GAAG,WAA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;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport {\n hashMessage,\n hashTypedData,\n type Hex,\n type SignableMessage,\n type TypedData,\n type TypedDataDefinition,\n type Chain,\n type Address,\n} from \"viem\";\n\nimport {\n packUOSignature,\n pack1271Signature,\n DEFAULT_OWNER_ENTITY_ID,\n} from \"../utils.js\";\n/**\n * Creates an object with methods for generating a dummy signature, signing user operation hashes, signing messages, and signing typed data.\n *\n * @example\n * ```ts\n * import { nativeSMASigner } from \"@account-kit/smart-contracts\";\n \n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n *\n * const MNEMONIC = \"...\":\n *\n * const account = createSMAV2Account({ config });\n *\n * const signer = LocalAccountSigner.mnemonicToAccountSigner(MNEMONIC);\n *\n * const messageSigner = nativeSMASigner(signer, chain, account.address);\n * ```\n *\n * @param {SmartAccountSigner} signer Signer to use for signing operations\n * @param {Chain} chain Chain object for the signer\n * @param {Address} accountAddress address of the smart account using this signer\n * @returns {object} an object with methods for signing operations and managing signatures\n */\nexport const nativeSMASigner = (\n signer: SmartAccountSigner,\n chain: Chain,\n accountAddress: Address\n) => {\n return {\n getDummySignature: (): Hex => {\n const dummyEcdsaSignature =\n \"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c\";\n\n return packUOSignature({\n // orderedHookData: [],\n validationSignature: dummyEcdsaSignature,\n });\n },\n\n signUserOperationHash: (uoHash: Hex): Promise<Hex> => {\n return signer.signMessage({ raw: uoHash }).then((signature: Hex) =>\n packUOSignature({\n // orderedHookData: [],\n validationSignature: signature,\n })\n );\n },\n\n // we apply the expected 1271 packing here since the account contract will expect it\n async signMessage({ message }: { message: SignableMessage }): Promise<Hex> {\n const hash = hashMessage(message);\n\n return pack1271Signature({\n validationSignature: await signer.signTypedData({\n domain: {\n chainId: Number(chain.id),\n verifyingContract: accountAddress,\n },\n types: {\n ReplaySafeHash: [{ name: \"hash\", type: \"bytes32\" }],\n },\n message: {\n hash,\n },\n primaryType: \"ReplaySafeHash\",\n }),\n entityId: DEFAULT_OWNER_ENTITY_ID,\n });\n },\n\n // TODO: maybe move \"sign deferred actions\" to a separate function?\n // we don't apply the expected 1271 packing since deferred sigs use typed data sigs and don't expect the 1271 packing\n signTypedData: async <\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | \"EIP712Domain\" = keyof typedData\n >(\n typedDataDefinition: TypedDataDefinition<typedData, primaryType>\n ): Promise<Hex> => {\n // the accounts domain already gives replay protection across accounts for deferred actions, so we don't need to apply another wrapping\n const isDeferredAction =\n typedDataDefinition?.primaryType === \"DeferredAction\" &&\n typedDataDefinition?.domain?.verifyingContract === accountAddress;\n\n return isDeferredAction\n ? signer.signTypedData(typedDataDefinition)\n : pack1271Signature({\n validationSignature: await signer.signTypedData({\n domain: {\n chainId: Number(chain.id),\n verifyingContract: accountAddress,\n },\n types: {\n ReplaySafeHash: [{ name: \"hash\", type: \"bytes32\" }],\n },\n message: {\n hash: await hashTypedData(typedDataDefinition),\n },\n primaryType: \"ReplaySafeHash\",\n }),\n entityId: DEFAULT_OWNER_ENTITY_ID,\n });\n },\n };\n};\n"]}
1
+ {"version":3,"file":"nativeSMASigner.js","sourceRoot":"","sources":["../../../../../src/ma-v2/account/nativeSMASigner.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,aAAa,GAOd,MAAM,MAAM,CAAC;AAEd,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,MAA0B,EAC1B,KAAY,EACZ,cAAuB,EACvB,EAAE;IACF,OAAO;QACL,iBAAiB,EAAE,GAAQ,EAAE;YAC3B,MAAM,mBAAmB,GACvB,sIAAsI,C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AAC;oBAChB,mBAAmB,EAAE,MAAM,MAAM,CAAC,aAAa,CAAC;wBAC9C,MAAM,EAAE;4BACN,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;4BACzB,iBAAiB,EAAE,cAAc;yBAClC;wBACD,KAAK,EAAE;4BACL,cAAc,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;yBACpD;wBACD,OAAO,EAAE;4BACP,IAAI,EAAE,MAAM,aAAa,CAAC,mBAAmB,CAAC;yBAC/C;wBACD,WAAW,EAAE,gBAAgB;qBAC9B,CAAC;oBACF,QAAQ,EAAE,uBAAuB;iBAClC,CAAC,CAAC;QACT,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport {\n hashMessage,\n hashTypedData,\n type Hex,\n type SignableMessage,\n type TypedData,\n type TypedDataDefinition,\n type Chain,\n type Address,\n} from \"viem\";\n\nimport {\n packUOSignature,\n pack1271Signature,\n DEFAULT_OWNER_ENTITY_ID,\n} from \"../utils.js\";\n/**\n * Creates an object with methods for generating a dummy signature, signing user operation hashes, signing messages, and signing typed data.\n *\n * @example\n * ```ts\n * import { nativeSMASigner } from \"@account-kit/smart-contracts\";\n \n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n *\n * const MNEMONIC = \"...\":\n *\n * const account = createModularAccountV2({ config });\n *\n * const signer = LocalAccountSigner.mnemonicToAccountSigner(MNEMONIC);\n *\n * const messageSigner = nativeSMASigner(signer, chain, account.address);\n * ```\n *\n * @param {SmartAccountSigner} signer Signer to use for signing operations\n * @param {Chain} chain Chain object for the signer\n * @param {Address} accountAddress address of the smart account using this signer\n * @returns {object} an object with methods for signing operations and managing signatures\n */\nexport const nativeSMASigner = (\n signer: SmartAccountSigner,\n chain: Chain,\n accountAddress: Address\n) => {\n return {\n getDummySignature: (): Hex => {\n const dummyEcdsaSignature =\n \"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c\";\n\n return packUOSignature({\n // orderedHookData: [],\n validationSignature: dummyEcdsaSignature,\n });\n },\n\n signUserOperationHash: (uoHash: Hex): Promise<Hex> => {\n return signer.signMessage({ raw: uoHash }).then((signature: Hex) =>\n packUOSignature({\n // orderedHookData: [],\n validationSignature: signature,\n })\n );\n },\n\n // we apply the expected 1271 packing here since the account contract will expect it\n async signMessage({ message }: { message: SignableMessage }): Promise<Hex> {\n const hash = hashMessage(message);\n\n return pack1271Signature({\n validationSignature: await signer.signTypedData({\n domain: {\n chainId: Number(chain.id),\n verifyingContract: accountAddress,\n },\n types: {\n ReplaySafeHash: [{ name: \"hash\", type: \"bytes32\" }],\n },\n message: {\n hash,\n },\n primaryType: \"ReplaySafeHash\",\n }),\n entityId: DEFAULT_OWNER_ENTITY_ID,\n });\n },\n\n // TODO: maybe move \"sign deferred actions\" to a separate function?\n // we don't apply the expected 1271 packing since deferred sigs use typed data sigs and don't expect the 1271 packing\n signTypedData: async <\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | \"EIP712Domain\" = keyof typedData\n >(\n typedDataDefinition: TypedDataDefinition<typedData, primaryType>\n ): Promise<Hex> => {\n // the accounts domain already gives replay protection across accounts for deferred actions, so we don't need to apply another wrapping\n const isDeferredAction =\n typedDataDefinition?.primaryType === \"DeferredAction\" &&\n typedDataDefinition?.domain?.verifyingContract === accountAddress;\n\n return isDeferredAction\n ? signer.signTypedData(typedDataDefinition)\n : pack1271Signature({\n validationSignature: await signer.signTypedData({\n domain: {\n chainId: Number(chain.id),\n verifyingContract: accountAddress,\n },\n types: {\n ReplaySafeHash: [{ name: \"hash\", type: \"bytes32\" }],\n },\n message: {\n hash: await hashTypedData(typedDataDefinition),\n },\n primaryType: \"ReplaySafeHash\",\n }),\n entityId: DEFAULT_OWNER_ENTITY_ID,\n });\n },\n };\n};\n"]}
@@ -1,8 +1,8 @@
1
1
  import { type GetEntryPointFromAccount, type SendUserOperationResult, type UserOperationOverridesParameter, type SmartAccountSigner } from "@aa-sdk/core";
2
2
  import { type Address, type Hex } from "viem";
3
3
  import type { HookConfig, ValidationConfig } from "../common/types.js";
4
- import { type SMAV2AccountClient } from "../../client/client.js";
5
- import { type MAV2Account } from "../../account/semiModularAccountV2.js";
4
+ import { type ModularAccountV2Client } from "../../client/client.js";
5
+ import { type ModularAccountV2 } from "../../account/common/modularAccountV2Base.js";
6
6
  export type InstallValidationParams<TSigner extends SmartAccountSigner = SmartAccountSigner> = {
7
7
  validationConfig: ValidationConfig;
8
8
  selectors: Hex[];
@@ -11,28 +11,30 @@ export type InstallValidationParams<TSigner extends SmartAccountSigner = SmartAc
11
11
  hookConfig: HookConfig;
12
12
  initData: Hex;
13
13
  }[];
14
- account?: MAV2Account<TSigner> | undefined;
15
- } & UserOperationOverridesParameter<GetEntryPointFromAccount<MAV2Account<TSigner>>>;
14
+ account?: ModularAccountV2<TSigner> | undefined;
15
+ } & UserOperationOverridesParameter<GetEntryPointFromAccount<ModularAccountV2<TSigner>>>;
16
16
  export type UninstallValidationParams<TSigner extends SmartAccountSigner = SmartAccountSigner> = {
17
17
  moduleAddress: Address;
18
18
  entityId: number;
19
19
  uninstallData: Hex;
20
20
  hookUninstallDatas: Hex[];
21
- account?: MAV2Account<TSigner> | undefined;
22
- } & UserOperationOverridesParameter<GetEntryPointFromAccount<MAV2Account<TSigner>>>;
21
+ account?: ModularAccountV2<TSigner> | undefined;
22
+ } & UserOperationOverridesParameter<GetEntryPointFromAccount<ModularAccountV2<TSigner>>>;
23
23
  export type InstallValidationActions<TSigner extends SmartAccountSigner = SmartAccountSigner> = {
24
24
  installValidation: (args: InstallValidationParams<TSigner>) => Promise<SendUserOperationResult>;
25
+ encodeInstallValidation: (args: InstallValidationParams<TSigner>) => Promise<Hex>;
25
26
  uninstallValidation: (args: UninstallValidationParams<TSigner>) => Promise<SendUserOperationResult>;
27
+ encodeUninstallValidation: (args: UninstallValidationParams<TSigner>) => Promise<Hex>;
26
28
  };
27
29
  /**
28
30
  * Provides validation installation and uninstallation functionalities for a MA v2 client, ensuring compatibility with `SmartAccountClient`.
29
31
  *
30
32
  * @example
31
33
  * ```ts
32
- * import { createSMAV2AccountClient, installValidationActions, getDefaultSingleSignerValidationModuleAddress, SingleSignerValidationModule } from "@account-kit/smart-contracts";
34
+ * import { createModularAccountV2Client, installValidationActions, getDefaultSingleSignerValidationModuleAddress, SingleSignerValidationModule } from "@account-kit/smart-contracts";
33
35
  * import { Address } from "viem";
34
36
  *
35
- * const client = (await createSMAV2AccountClient({ ... })).extend(installValidationActions);
37
+ * const client = (await createModularAccountV2Client({ ... })).extend(installValidationActions);
36
38
  * const sessionKeyAddress: Address = "0x1234";
37
39
  * const sessionKeyEntityId: number = 1;
38
40
  *
@@ -68,4 +70,4 @@ export type InstallValidationActions<TSigner extends SmartAccountSigner = SmartA
68
70
  * @param {object} client - The client instance which provides account and sendUserOperation functionality.
69
71
  * @returns {object} - An object containing two methods, `installValidation` and `uninstallValidation`.
70
72
  */
71
- export declare const installValidationActions: <TSigner extends SmartAccountSigner = SmartAccountSigner>(client: SMAV2AccountClient<TSigner>) => InstallValidationActions<TSigner>;
73
+ export declare const installValidationActions: <TSigner extends SmartAccountSigner = SmartAccountSigner>(client: ModularAccountV2Client<TSigner>) => InstallValidationActions<TSigner>;