@account-kit/smart-contracts 4.12.1-alpha.0 → 4.13.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 (51) 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/single-signer-validation/signer.d.ts +1 -1
  23. package/dist/esm/src/ma-v2/modules/single-signer-validation/signer.js +1 -1
  24. package/dist/esm/src/ma-v2/modules/single-signer-validation/signer.js.map +1 -1
  25. package/dist/types/src/index.d.ts +5 -0
  26. package/dist/types/src/index.d.ts.map +1 -1
  27. package/dist/types/src/ma-v2/account/common/modularAccountV2Base.d.ts +40 -0
  28. package/dist/types/src/ma-v2/account/common/modularAccountV2Base.d.ts.map +1 -0
  29. package/dist/types/src/ma-v2/account/modularAccountV2.d.ts +17 -0
  30. package/dist/types/src/ma-v2/account/modularAccountV2.d.ts.map +1 -0
  31. package/dist/types/src/ma-v2/account/nativeSMASigner.d.ts +1 -1
  32. package/dist/types/src/ma-v2/actions/install-validation/installValidation.d.ts +11 -9
  33. package/dist/types/src/ma-v2/actions/install-validation/installValidation.d.ts.map +1 -1
  34. package/dist/types/src/ma-v2/client/client.d.ts +7 -6
  35. package/dist/types/src/ma-v2/client/client.d.ts.map +1 -1
  36. package/dist/types/src/ma-v2/index.d.ts +0 -4
  37. package/dist/types/src/ma-v2/index.d.ts.map +1 -1
  38. package/dist/types/src/ma-v2/modules/single-signer-validation/signer.d.ts +1 -1
  39. package/package.json +6 -6
  40. package/src/index.ts +7 -0
  41. package/src/ma-v2/account/{semiModularAccountV2.ts → common/modularAccountV2Base.ts} +62 -105
  42. package/src/ma-v2/account/modularAccountV2.ts +193 -0
  43. package/src/ma-v2/account/nativeSMASigner.ts +1 -1
  44. package/src/ma-v2/actions/install-validation/installValidation.ts +75 -36
  45. package/src/ma-v2/client/client.ts +54 -34
  46. package/src/ma-v2/index.ts +0 -5
  47. package/src/ma-v2/modules/single-signer-validation/signer.ts +1 -1
  48. package/dist/esm/src/ma-v2/account/semiModularAccountV2.d.ts +0 -41
  49. package/dist/esm/src/ma-v2/account/semiModularAccountV2.js.map +0 -1
  50. package/dist/types/src/ma-v2/account/semiModularAccountV2.d.ts +0 -42
  51. package/dist/types/src/ma-v2/account/semiModularAccountV2.d.ts.map +0 -1
@@ -1,14 +1,15 @@
1
1
  import { type SmartAccountClient, type SmartAccountSigner, type SmartAccountClientConfig, type NotType } from "@aa-sdk/core";
2
2
  import { type Chain, type Transport } from "viem";
3
- import { type CreateSMAV2AccountParams, type MAV2Account } from "../account/semiModularAccountV2.js";
3
+ import { type CreateModularAccountV2Params } from "../account/modularAccountV2.js";
4
4
  import { type AlchemySmartAccountClientConfig, type AlchemyTransport } from "@account-kit/infra";
5
5
  import type { LightAccount } from "../../light-account/accounts/account.js";
6
- export type SMAV2AccountClient<TSigner extends SmartAccountSigner = SmartAccountSigner, TChain extends Chain = Chain, TTransport extends Transport | AlchemyTransport = Transport> = SmartAccountClient<TTransport, TChain, MAV2Account<TSigner>>;
7
- export type CreateSMAV2AccountClientParams<TTransport extends Transport = Transport, TChain extends Chain = Chain, TSigner extends SmartAccountSigner = SmartAccountSigner> = CreateSMAV2AccountParams<TTransport, TSigner> & Omit<SmartAccountClientConfig<TTransport, TChain>, "transport" | "account" | "chain">;
8
- export type CreateSMAV2AlchemyAccountClientParams<TTransport extends Transport = Transport, TChain extends Chain = Chain, TSigner extends SmartAccountSigner = SmartAccountSigner> = Omit<CreateSMAV2AccountClientParams<TTransport, TChain, TSigner>, "transport"> & Omit<AlchemySmartAccountClientConfig<TChain, LightAccount<TSigner>>, "account"> & {
6
+ import type { ModularAccountV2 } from "../account/common/modularAccountV2Base.js";
7
+ export type ModularAccountV2Client<TSigner extends SmartAccountSigner = SmartAccountSigner, TChain extends Chain = Chain, TTransport extends Transport | AlchemyTransport = Transport> = SmartAccountClient<TTransport, TChain, ModularAccountV2<TSigner>>;
8
+ export type CreateModularAccountV2ClientParams<TTransport extends Transport = Transport, TChain extends Chain = Chain, TSigner extends SmartAccountSigner = SmartAccountSigner> = CreateModularAccountV2Params<TTransport, TSigner> & Omit<SmartAccountClientConfig<TTransport, TChain>, "transport" | "account" | "chain">;
9
+ export type CreateModularAccountV2AlchemyClientParams<TTransport extends Transport = Transport, TChain extends Chain = Chain, TSigner extends SmartAccountSigner = SmartAccountSigner> = Omit<CreateModularAccountV2ClientParams<TTransport, TChain, TSigner>, "transport"> & Omit<AlchemySmartAccountClientConfig<TChain, LightAccount<TSigner>>, "account"> & {
9
10
  paymasterAndData?: never;
10
11
  dummyPaymasterAndData?: never;
11
12
  };
12
- export declare function createSMAV2AccountClient<TChain extends Chain = Chain, TSigner extends SmartAccountSigner = SmartAccountSigner>(args: CreateSMAV2AlchemyAccountClientParams<AlchemyTransport, TChain, TSigner>): Promise<SMAV2AccountClient<TSigner, TChain, AlchemyTransport>>;
13
- export declare function createSMAV2AccountClient<TTransport extends Transport = Transport, TChain extends Chain = Chain, TSigner extends SmartAccountSigner = SmartAccountSigner>(args: CreateSMAV2AccountClientParams<TTransport, TChain, TSigner> & NotType<TTransport, AlchemyTransport>): Promise<SMAV2AccountClient<TSigner, TChain>>;
13
+ export declare function createModularAccountV2Client<TChain extends Chain = Chain, TSigner extends SmartAccountSigner = SmartAccountSigner>(args: CreateModularAccountV2AlchemyClientParams<AlchemyTransport, TChain, TSigner>): Promise<ModularAccountV2Client<TSigner, TChain, AlchemyTransport>>;
14
+ export declare function createModularAccountV2Client<TTransport extends Transport = Transport, TChain extends Chain = Chain, TSigner extends SmartAccountSigner = SmartAccountSigner>(args: CreateModularAccountV2ClientParams<TTransport, TChain, TSigner> & NotType<TTransport, AlchemyTransport>): Promise<ModularAccountV2Client<TSigner, TChain>>;
14
15
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../src/ma-v2/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,OAAO,EAEb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,MAAM,CAAC;AAElD,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,WAAW,EACjB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAGL,KAAK,+BAA+B,EACpC,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,y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";
4
4
  export { semiModularAccountStorageAbi } from "./abis/semiModularAccountStorageAbi.js";
5
5
  export { nativeSMASigner } from "./account/nativeSMASigner.js";
6
- export type * from "./account/semiModularAccountV2.js";
7
- export { createSMAV2Account } from "./account/semiModularAccountV2.js";
8
6
  export type { ModuleEntity, ValidationConfig, HookConfig, ValidationData, } from "./actions/common/types.js";
9
7
  export { HookType } from "./actions/common/types.js";
10
8
  export { serializeValidationConfig, serializeHookConfig, serializeModuleEntity, } from "./actions/common/utils.js";
11
9
  export type * from "./actions/install-validation/installValidation.js";
12
10
  export { installValidationActions } from "./actions/install-validation/installValidation.js";
13
- export type * from "./client/client.js";
14
- export { createSMAV2AccountClient } from "./client/client.js";
15
11
  export { getDefaultAllowlistModuleAddress, getDefaultNativeTokenLimitModuleAddress, getDefaultPaymasterGuardModuleAddress, getDefaultSingleSignerValidationModuleAddress, getDefaultTimeRangeModuleAddress, getDefaultWebauthnValidationModuleAddress, } from "./modules/utils.js";
16
12
  export { allowlistModuleAbi } from "./modules/allowlist-module/abis/allowlistModuleAbi.js";
17
13
  export { AllowlistModule } from "./modules/allowlist-module/module.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ma-v2/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AACxF,OAAO,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AAEtF,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,mBAAmB,mCAAmC,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAEvE,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,cAAc,GACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,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;AACxF,OAAO,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AAEtF,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,cAAc,GACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AACnC,mBAAmB,mDAAmD,CAAC;AACvE,OAAO,EAAE,wBAAwB,EAAE,MAAM,mDAAmD,CAAC;AAE7F,OAAO,EACL,gCAAgC,EAChC,uCAAuC,EACvC,qCAAqC,EACrC,6CAA6C,EAC7C,gCAAgC,EAChC,yCAAyC,GAC1C,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uDAAuD,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uEAAuE,CAAC;AAClH,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,kEAAkE,CAAC;AAC3G,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EAAE,+BAA+B,EAAE,MAAM,4EAA4E,CAAC;AAC7H,OAAO,EAAE,4BAA4B,EAAE,MAAM,8CAA8C,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,MAAM,wDAAwD,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,6DAA6D,CAAC"}
@@ -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
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@account-kit/smart-contracts",
3
- "version": "4.12.1-alpha.0",
3
+ "version": "4.13.0",
4
4
  "description": "aa-sdk compatible interfaces for Alchemy Smart Accounts",
5
5
  "author": "Alchemy",
6
6
  "license": "MIT",
@@ -52,7 +52,7 @@
52
52
  "test:run": "vitest run"
53
53
  },
54
54
  "devDependencies": {
55
- "@account-kit/plugingen": "^4.12.1-alpha.0",
55
+ "@account-kit/plugingen": "^4.13.0",
56
56
  "change-case": "^5.1.2",
57
57
  "dedent": "^1.5.1",
58
58
  "dotenv": "^16.3.1",
@@ -72,12 +72,12 @@
72
72
  "url": "https://github.com/alchemyplatform/aa-sdk/issues"
73
73
  },
74
74
  "homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
75
- "gitHead": "7835fad48bb913cc0b9adfb82fc98610e5cde0b1",
75
+ "gitHead": "6865bd7b49bc7db064bca7026914e4299febdb34",
76
76
  "dependencies": {
77
- "@aa-sdk/core": "^4.12.1-alpha.0",
78
- "@account-kit/infra": "^4.12.1-alpha.0"
77
+ "@aa-sdk/core": "^4.13.0",
78
+ "@account-kit/infra": "^4.13.0"
79
79
  },
80
80
  "peerDependencies": {
81
- "viem": "^2.20.0"
81
+ "viem": "^2.22.6"
82
82
  }
83
83
  }
package/src/index.ts CHANGED
@@ -115,3 +115,10 @@ export {
115
115
  getMAInitializationData,
116
116
  getMSCAUpgradeToData,
117
117
  } from "./msca/utils.js";
118
+
119
+ // ma v2 types
120
+ export type * from "./ma-v2/account/modularAccountV2.js";
121
+ export type * from "./ma-v2/account/common/modularAccountV2Base.js";
122
+ export { createModularAccountV2 } from "./ma-v2/account/modularAccountV2.js";
123
+ export type * from "./ma-v2/client/client.js";
124
+ export { createModularAccountV2Client } from "./ma-v2/client/client.js";
@@ -1,41 +1,33 @@
1
- import type {
2
- EntryPointDef,
3
- SmartAccountSigner,
4
- AccountOp,
5
- SmartContractAccountWithSigner,
6
- ToSmartContractAccountParams,
7
- } from "@aa-sdk/core";
8
1
  import {
9
2
  createBundlerClient,
10
3
  getEntryPoint,
11
- toSmartContractAccount,
12
4
  InvalidEntityIdError,
13
5
  InvalidNonceKeyError,
14
- getAccountAddress,
6
+ toSmartContractAccount,
7
+ type AccountOp,
8
+ type SmartAccountSigner,
9
+ type SmartContractAccountWithSigner,
10
+ type ToSmartContractAccountParams,
15
11
  } from "@aa-sdk/core";
12
+ import { DEFAULT_OWNER_ENTITY_ID } from "../../utils.js";
16
13
  import {
17
- concatHex,
18
- encodeFunctionData,
19
- getContract,
20
- maxUint32,
21
- maxUint152,
22
- zeroAddress,
14
+ type Hex,
23
15
  type Address,
24
16
  type Chain,
25
- type Hex,
26
17
  type Transport,
18
+ encodeFunctionData,
19
+ maxUint32,
20
+ zeroAddress,
21
+ getContract,
22
+ concatHex,
23
+ maxUint152,
27
24
  } from "viem";
28
- import { accountFactoryAbi } from "../abis/accountFactoryAbi.js";
29
- import {
30
- getDefaultMAV2FactoryAddress,
31
- DEFAULT_OWNER_ENTITY_ID,
32
- } from "../utils.js";
33
- import { singleSignerMessageSigner } from "../modules/single-signer-validation/signer.js";
34
- import { nativeSMASigner } from "./nativeSMASigner.js";
35
- import { modularAccountAbi } from "../abis/modularAccountAbi.js";
36
- import { serializeModuleEntity } from "../actions/common/utils.js";
25
+ import { modularAccountAbi } from "../../abis/modularAccountAbi.js";
26
+ import { serializeModuleEntity } from "../../actions/common/utils.js";
27
+ import { nativeSMASigner } from "../nativeSMASigner.js";
28
+ import { singleSignerMessageSigner } from "../../modules/single-signer-validation/signer.js";
37
29
 
38
- const executeUserOpSelector: Hex = "0x8DD7712F";
30
+ export const executeUserOpSelector: Hex = "0x8DD7712F";
39
31
 
40
32
  export type SignerEntity = {
41
33
  isGlobalValidation: boolean;
@@ -66,9 +58,9 @@ export type ValidationDataParams =
66
58
  entityId: number;
67
59
  };
68
60
 
69
- export type MAV2Account<
61
+ export type ModularAccountV2<
70
62
  TSigner extends SmartAccountSigner = SmartAccountSigner
71
- > = SmartContractAccountWithSigner<"MAV2Account", TSigner, "0.7.0"> & {
63
+ > = SmartContractAccountWithSigner<"ModularAccountV2", TSigner, "0.7.0"> & {
72
64
  signerEntity: SignerEntity;
73
65
  getExecutionData: (selector: Hex) => Promise<ExecutionDataView>;
74
66
  getValidationData: (
@@ -77,48 +69,35 @@ export type MAV2Account<
77
69
  encodeCallData: (callData: Hex) => Promise<Hex>;
78
70
  };
79
71
 
80
- export type CreateSMAV2AccountParams<
81
- TTransport extends Transport = Transport,
82
- TSigner extends SmartAccountSigner = SmartAccountSigner
83
- > = Pick<
84
- ToSmartContractAccountParams<"MAV2Account", TTransport, Chain, "0.7.0">,
85
- "transport" | "chain" | "accountAddress"
72
+ export type CreateMAV2BaseParams<
73
+ TSigner extends SmartAccountSigner = SmartAccountSigner,
74
+ TTransport extends Transport = Transport
75
+ > = Omit<
76
+ ToSmartContractAccountParams<"ModularAccountV2", TTransport, Chain, "0.7.0">,
77
+ // Implements the following methods required by `toSmartContractAccount`, and passes through any other parameters.
78
+ | "encodeExecute"
79
+ | "encodeBatchExecute"
80
+ | "getNonce"
81
+ | "signMessage"
82
+ | "signTypedData"
83
+ | "getDummySignature"
86
84
  > & {
87
85
  signer: TSigner;
88
- salt?: bigint;
89
- factoryAddress?: Address;
90
- initCode?: Hex;
91
- initialOwner?: Address;
92
- entryPoint?: EntryPointDef<"0.7.0", Chain>;
93
86
  signerEntity?: SignerEntity;
87
+ accountAddress: Address;
94
88
  };
95
89
 
96
- export async function createSMAV2Account<
97
- TTransport extends Transport = Transport,
90
+ export type CreateMAV2BaseReturnType<
98
91
  TSigner extends SmartAccountSigner = SmartAccountSigner
99
- >(
100
- config: CreateSMAV2AccountParams<TTransport, TSigner>
101
- ): Promise<MAV2Account<TSigner>>;
92
+ > = Promise<ModularAccountV2<TSigner>>;
102
93
 
103
- /**
104
- * Creates an SMAV2 account using defined parameters including chain, signer, salt, factory address, and more.
105
- * Handles account initialization code, nonce generation, transaction encoding, and more to construct a modular account with optional validation hooks.
106
- *
107
- * @param {CreateSMAV2AccountParams} config Configuration parameters for creating an SMAV2 account. Includes chain details, signer, salt, factory address, and more.
108
- * @returns {Promise<MAV2Account>} A promise that resolves to an `MAV2Account` providing methods for nonce retrieval, transaction execution, and more.
109
- */
110
- export async function createSMAV2Account(
111
- config: CreateSMAV2AccountParams
112
- ): Promise<MAV2Account> {
94
+ export async function createMAv2Base<
95
+ TSigner extends SmartAccountSigner = SmartAccountSigner
96
+ >(config: CreateMAV2BaseParams<TSigner>): CreateMAV2BaseReturnType<TSigner> {
113
97
  const {
114
98
  transport,
115
99
  chain,
116
100
  signer,
117
- salt = 0n,
118
- factoryAddress = getDefaultMAV2FactoryAddress(chain),
119
- initCode,
120
- initialOwner,
121
- accountAddress,
122
101
  entryPoint = getEntryPoint(chain, { version: "0.7.0" }),
123
102
  signerEntity = {
124
103
  isGlobalValidation: true,
@@ -128,6 +107,8 @@ export async function createSMAV2Account(
128
107
  isGlobalValidation = true,
129
108
  entityId = DEFAULT_OWNER_ENTITY_ID,
130
109
  } = {},
110
+ accountAddress,
111
+ ...remainingToSmartContractAccountParams
131
112
  } = config;
132
113
 
133
114
  if (entityId > Number(maxUint32)) {
@@ -139,24 +120,6 @@ export async function createSMAV2Account(
139
120
  chain,
140
121
  });
141
122
 
142
- const getAccountInitCode = async () => {
143
- if (initCode) {
144
- return initCode;
145
- }
146
-
147
- // If an initial owner is not provided, use the signer's address
148
- const ownerAddress = initialOwner ?? (await signer.getAddress());
149
-
150
- return concatHex([
151
- factoryAddress,
152
- encodeFunctionData({
153
- abi: accountFactoryAbi,
154
- functionName: "createSemiModularAccount",
155
- args: [ownerAddress, salt],
156
- }),
157
- ]);
158
- };
159
-
160
123
  const encodeExecute: (tx: AccountOp) => Promise<Hex> = async ({
161
124
  target,
162
125
  data,
@@ -185,29 +148,10 @@ export async function createSMAV2Account(
185
148
  })
186
149
  );
187
150
 
188
- const _accountAddress = await getAccountAddress({
189
- client,
190
- entryPoint,
191
- accountAddress,
192
- getAccountInitCode,
193
- });
194
-
195
- const baseAccount = await toSmartContractAccount({
196
- transport,
197
- chain,
198
- entryPoint,
199
- accountAddress: _accountAddress,
200
- source: `MAV2Account`,
201
- encodeExecute,
202
- encodeBatchExecute,
203
- getAccountInitCode,
204
- ...(entityId === DEFAULT_OWNER_ENTITY_ID
205
- ? nativeSMASigner(signer, chain, _accountAddress)
206
- : singleSignerMessageSigner(signer, chain, _accountAddress, entityId)),
207
- });
208
-
151
+ const isAccountDeployed: () => Promise<boolean> = async () =>
152
+ !!(await client.getCode({ address: accountAddress }));
209
153
  // TODO: add deferred action flag
210
- const getAccountNonce = async (nonceKey: bigint = 0n): Promise<bigint> => {
154
+ const getNonce = async (nonceKey: bigint = 0n): Promise<bigint> => {
211
155
  if (nonceKey > maxUint152) {
212
156
  throw new InvalidNonceKeyError(nonceKey);
213
157
  }
@@ -220,23 +164,23 @@ export async function createSMAV2Account(
220
164
 
221
165
  const fullNonceKey: bigint =
222
166
  (nonceKey << 40n) +
223
- BigInt(entityId << 8) +
167
+ (BigInt(entityId) << 8n) +
224
168
  (isGlobalValidation ? 1n : 0n);
225
169
 
226
170
  return entryPointContract.read.getNonce([
227
- _accountAddress,
171
+ accountAddress,
228
172
  fullNonceKey,
229
173
  ]) as Promise<bigint>;
230
174
  };
231
175
 
232
176
  const accountContract = getContract({
233
- address: _accountAddress,
177
+ address: accountAddress,
234
178
  abi: modularAccountAbi,
235
179
  client,
236
180
  });
237
181
 
238
182
  const getExecutionData = async (selector: Hex) => {
239
- if (!(await baseAccount.isAccountDeployed())) {
183
+ if (!(await isAccountDeployed())) {
240
184
  return {
241
185
  module: zeroAddress,
242
186
  skipRuntimeValidation: false,
@@ -249,7 +193,7 @@ export async function createSMAV2Account(
249
193
  };
250
194
 
251
195
  const getValidationData = async (args: ValidationDataParams) => {
252
- if (!(await baseAccount.isAccountDeployed())) {
196
+ if (!(await isAccountDeployed())) {
253
197
  return {
254
198
  validationHooks: [],
255
199
  executionHooks: [],
@@ -277,9 +221,22 @@ export async function createSMAV2Account(
277
221
  : callData;
278
222
  };
279
223
 
224
+ const baseAccount = await toSmartContractAccount({
225
+ ...remainingToSmartContractAccountParams,
226
+ transport,
227
+ chain,
228
+ entryPoint,
229
+ accountAddress,
230
+ encodeExecute,
231
+ encodeBatchExecute,
232
+ getNonce,
233
+ ...(entityId === DEFAULT_OWNER_ENTITY_ID
234
+ ? nativeSMASigner(signer, chain, accountAddress)
235
+ : singleSignerMessageSigner(signer, chain, accountAddress, entityId)),
236
+ });
237
+
280
238
  return {
281
239
  ...baseAccount,
282
- getAccountNonce,
283
240
  getSigner: () => signer,
284
241
  signerEntity,
285
242
  getExecutionData,
@@ -0,0 +1,193 @@
1
+ import type {
2
+ EntryPointDef,
3
+ SmartAccountSigner,
4
+ ToSmartContractAccountParams,
5
+ } from "@aa-sdk/core";
6
+ import {
7
+ createBundlerClient,
8
+ getEntryPoint,
9
+ getAccountAddress,
10
+ EntityIdOverrideError,
11
+ InvalidModularAccountV2Mode,
12
+ } from "@aa-sdk/core";
13
+ import {
14
+ concatHex,
15
+ encodeFunctionData,
16
+ type Address,
17
+ type Chain,
18
+ type Hex,
19
+ type Transport,
20
+ } from "viem";
21
+ import { accountFactoryAbi } from "../abis/accountFactoryAbi.js";
22
+ import { getDefaultMAV2FactoryAddress } from "../utils.js";
23
+ import {
24
+ type SignerEntity,
25
+ type ModularAccountV2,
26
+ createMAv2Base,
27
+ } from "./common/modularAccountV2Base.js";
28
+ import { DEFAULT_OWNER_ENTITY_ID } from "../utils.js";
29
+
30
+ export type CreateModularAccountV2Params<
31
+ TTransport extends Transport = Transport,
32
+ TSigner extends SmartAccountSigner = SmartAccountSigner
33
+ > = (Pick<
34
+ ToSmartContractAccountParams<"ModularAccountV2", TTransport, Chain, "0.7.0">,
35
+ "transport" | "chain" | "accountAddress"
36
+ > & {
37
+ signer: TSigner;
38
+ entryPoint?: EntryPointDef<"0.7.0", Chain>;
39
+ signerEntity?: SignerEntity;
40
+ }) &
41
+ (
42
+ | {
43
+ mode?: "default";
44
+ salt?: bigint;
45
+ factoryAddress?: Address;
46
+ initCode?: Hex;
47
+ }
48
+ | {
49
+ mode: "7702";
50
+ }
51
+ );
52
+
53
+ export async function createModularAccountV2<
54
+ TTransport extends Transport = Transport,
55
+ TSigner extends SmartAccountSigner = SmartAccountSigner
56
+ >(
57
+ config: CreateModularAccountV2Params<TTransport, TSigner>
58
+ ): Promise<ModularAccountV2<TSigner>>;
59
+
60
+ /**
61
+ * Creates a ModularAccount V2 account, with the mode depending on the provided "mode" field.
62
+ * Possible modes include: "default", which is SMA Bytecode, and "7702", which is SMA 7702.
63
+ * Handles nonce generation, transaction encoding, and mode variant-specific behavior like initcode construction.
64
+ *
65
+ * @example
66
+ * ```ts twoslash
67
+ * import { createModularAccountV2 } from "@account-kit/smart-contracts";
68
+ * import { LocalAccountSigner } from "@aa-sdk/core";
69
+ * import { alchemy, sepolia } from "@account-kit/infra";
70
+ *
71
+ * const MNEMONIC = "...";
72
+ * const RPC_URL = "...";
73
+ *
74
+ * const signer = LocalAccountSigner.mnemonicToAccountSigner(MNEMONIC);
75
+ *
76
+ * const chain = sepolia;
77
+ *
78
+ * const transport = alchemy({ rpcUrl: RPC_URL });
79
+ *
80
+ *
81
+ * const modularAccountV2 = await createModularAccountV2({
82
+ * mode: "default", // or "7702"
83
+ * chain,
84
+ * signer,
85
+ * transport,
86
+ * });
87
+ * ```
88
+ *
89
+ * @param {CreateModularAccountV2Params} config Configuration parameters for creating a Modular Account V2.
90
+ * @returns {Promise<ModularAccountV2>} A promise that resolves to an `ModularAccountV2` providing methods for nonce retrieval, transaction execution, and more.
91
+ */
92
+ export async function createModularAccountV2(
93
+ config: CreateModularAccountV2Params
94
+ ): Promise<ModularAccountV2> {
95
+ const {
96
+ transport,
97
+ chain,
98
+ signer,
99
+ accountAddress: _accountAddress,
100
+ entryPoint = getEntryPoint(chain, { version: "0.7.0" }),
101
+ signerEntity = {
102
+ isGlobalValidation: true,
103
+ entityId: DEFAULT_OWNER_ENTITY_ID,
104
+ },
105
+ signerEntity: { entityId = DEFAULT_OWNER_ENTITY_ID } = {},
106
+ } = config;
107
+
108
+ const client = createBundlerClient({
109
+ transport,
110
+ chain,
111
+ });
112
+
113
+ const accountFunctions = await (async () => {
114
+ switch (config.mode) {
115
+ case "7702": {
116
+ const getAccountInitCode = async (): Promise<Hex> => {
117
+ return "0x";
118
+ };
119
+ const signerAddress = await signer.getAddress();
120
+ const accountAddress = _accountAddress ?? signerAddress;
121
+ if (
122
+ entityId === DEFAULT_OWNER_ENTITY_ID &&
123
+ signerAddress !== accountAddress
124
+ ) {
125
+ throw new EntityIdOverrideError();
126
+ }
127
+
128
+ const implementation: Address =
129
+ "0x69007702764179f14F51cdce752f4f775d74E139";
130
+
131
+ const getImplementationAddress = async () => implementation;
132
+
133
+ return {
134
+ getAccountInitCode,
135
+ accountAddress,
136
+ getImplementationAddress,
137
+ };
138
+ }
139
+ case "default":
140
+ case undefined: {
141
+ const {
142
+ salt = 0n,
143
+ factoryAddress = getDefaultMAV2FactoryAddress(chain),
144
+ initCode,
145
+ } = config;
146
+
147
+ const getAccountInitCode = async () => {
148
+ if (initCode) {
149
+ return initCode;
150
+ }
151
+
152
+ return concatHex([
153
+ factoryAddress,
154
+ encodeFunctionData({
155
+ abi: accountFactoryAbi,
156
+ functionName: "createSemiModularAccount",
157
+ args: [await signer.getAddress(), salt],
158
+ }),
159
+ ]);
160
+ };
161
+
162
+ const accountAddress = await getAccountAddress({
163
+ client,
164
+ entryPoint,
165
+ accountAddress: _accountAddress,
166
+ getAccountInitCode,
167
+ });
168
+
169
+ return {
170
+ getAccountInitCode,
171
+ accountAddress,
172
+ };
173
+ }
174
+ default:
175
+ assertNever(config);
176
+ }
177
+ })();
178
+
179
+ return createMAv2Base({
180
+ source: "ModularAccountV2",
181
+ transport,
182
+ chain,
183
+ signer,
184
+ entryPoint,
185
+ signerEntity,
186
+ ...accountFunctions,
187
+ });
188
+ }
189
+
190
+ // 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.
191
+ function assertNever(_valid: never): never {
192
+ throw new InvalidModularAccountV2Mode();
193
+ }
@@ -26,7 +26,7 @@ import {
26
26
  *
27
27
  * const MNEMONIC = "...":
28
28
  *
29
- * const account = createSMAV2Account({ config });
29
+ * const account = createModularAccountV2({ config });
30
30
  *
31
31
  * const signer = LocalAccountSigner.mnemonicToAccountSigner(MNEMONIC);
32
32
  *