@account-kit/smart-contracts 4.41.0 → 4.42.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 (37) hide show
  1. package/dist/esm/src/ma-v2/account/common/modularAccountV2Base.d.ts +17 -3
  2. package/dist/esm/src/ma-v2/account/common/modularAccountV2Base.js +23 -5
  3. package/dist/esm/src/ma-v2/account/common/modularAccountV2Base.js.map +1 -1
  4. package/dist/esm/src/ma-v2/account/modularAccountV2.d.ts +15 -1
  5. package/dist/esm/src/ma-v2/account/modularAccountV2.js +67 -7
  6. package/dist/esm/src/ma-v2/account/modularAccountV2.js.map +1 -1
  7. package/dist/esm/src/ma-v2/client/client.d.ts +15 -7
  8. package/dist/esm/src/ma-v2/client/client.js +23 -7
  9. package/dist/esm/src/ma-v2/client/client.js.map +1 -1
  10. package/dist/esm/src/ma-v2/errors.d.ts +22 -0
  11. package/dist/esm/src/ma-v2/errors.js +44 -0
  12. package/dist/esm/src/ma-v2/errors.js.map +1 -0
  13. package/dist/esm/src/ma-v2/index.d.ts +1 -0
  14. package/dist/esm/src/ma-v2/index.js +1 -0
  15. package/dist/esm/src/ma-v2/index.js.map +1 -1
  16. package/dist/esm/src/ma-v2/modules/webauthn-validation/signingMethods.d.ts +36 -0
  17. package/dist/esm/src/ma-v2/modules/webauthn-validation/signingMethods.js +119 -0
  18. package/dist/esm/src/ma-v2/modules/webauthn-validation/signingMethods.js.map +1 -0
  19. package/dist/types/src/ma-v2/account/common/modularAccountV2Base.d.ts +17 -3
  20. package/dist/types/src/ma-v2/account/common/modularAccountV2Base.d.ts.map +1 -1
  21. package/dist/types/src/ma-v2/account/modularAccountV2.d.ts +15 -1
  22. package/dist/types/src/ma-v2/account/modularAccountV2.d.ts.map +1 -1
  23. package/dist/types/src/ma-v2/client/client.d.ts +15 -7
  24. package/dist/types/src/ma-v2/client/client.d.ts.map +1 -1
  25. package/dist/types/src/ma-v2/errors.d.ts +23 -0
  26. package/dist/types/src/ma-v2/errors.d.ts.map +1 -0
  27. package/dist/types/src/ma-v2/index.d.ts +1 -0
  28. package/dist/types/src/ma-v2/index.d.ts.map +1 -1
  29. package/dist/types/src/ma-v2/modules/webauthn-validation/signingMethods.d.ts +37 -0
  30. package/dist/types/src/ma-v2/modules/webauthn-validation/signingMethods.d.ts.map +1 -0
  31. package/package.json +5 -5
  32. package/src/ma-v2/account/common/modularAccountV2Base.ts +71 -8
  33. package/src/ma-v2/account/modularAccountV2.ts +115 -9
  34. package/src/ma-v2/client/client.ts +73 -17
  35. package/src/ma-v2/errors.ts +33 -0
  36. package/src/ma-v2/index.ts +1 -0
  37. package/src/ma-v2/modules/webauthn-validation/signingMethods.ts +158 -0
@@ -1,5 +1,6 @@
1
- import { type SmartAccountSigner, type SmartContractAccountWithSigner, type ToSmartContractAccountParams } from "@aa-sdk/core";
1
+ import { type SmartAccountSigner, type SmartContractAccountWithSigner, type ToSmartContractAccountParams, type SmartContractAccount } from "@aa-sdk/core";
2
2
  import { type Hex, type Address, type Chain, type Transport } from "viem";
3
+ import type { ToWebAuthnAccountParameters } from "viem/account-abstraction";
3
4
  export declare const executeUserOpSelector: Hex;
4
5
  export type SignerEntity = {
5
6
  isGlobalValidation: boolean;
@@ -30,11 +31,24 @@ export type ModularAccountV2<TSigner extends SmartAccountSigner = SmartAccountSi
30
31
  getValidationData: (args: ValidationDataParams) => Promise<ValidationDataView>;
31
32
  encodeCallData: (callData: Hex) => Promise<Hex>;
32
33
  };
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" | "prepareSign" | "formatSign"> & {
34
+ export type WebauthnModularAccountV2 = SmartContractAccount<"ModularAccountV2", "0.7.0"> & {
35
+ params: ToWebAuthnAccountParameters;
36
+ signerEntity: SignerEntity;
37
+ getExecutionData: (selector: Hex) => Promise<ExecutionDataView>;
38
+ getValidationData: (args: ValidationDataParams) => Promise<ValidationDataView>;
39
+ encodeCallData: (callData: Hex) => Promise<Hex>;
40
+ };
41
+ export type CreateMAV2BaseParams<TSigner extends SmartAccountSigner | undefined = SmartAccountSigner | undefined, TTransport extends Transport = Transport> = Omit<ToSmartContractAccountParams<"ModularAccountV2", TTransport, Chain, "0.7.0">, "encodeExecute" | "encodeBatchExecute" | "getNonce" | "signMessage" | "signTypedData" | "getDummySignature" | "prepareSign" | "formatSign"> & {
34
42
  signer: TSigner;
35
43
  signerEntity?: SignerEntity;
36
44
  accountAddress: Address;
37
45
  deferredAction?: Hex;
38
46
  };
47
+ export type CreateWebauthnMAV2BaseParams = Omit<CreateMAV2BaseParams, "signer"> & {
48
+ credential: ToWebAuthnAccountParameters["credential"];
49
+ getFn?: ToWebAuthnAccountParameters["getFn"] | undefined;
50
+ rpId?: ToWebAuthnAccountParameters["rpId"] | undefined;
51
+ };
39
52
  export type CreateMAV2BaseReturnType<TSigner extends SmartAccountSigner = SmartAccountSigner> = Promise<ModularAccountV2<TSigner>>;
40
- export declare function createMAv2Base<TSigner extends SmartAccountSigner = SmartAccountSigner>(config: CreateMAV2BaseParams<TSigner>): CreateMAV2BaseReturnType<TSigner>;
53
+ export declare function createMAv2Base(config: CreateWebauthnMAV2BaseParams): Promise<WebauthnModularAccountV2>;
54
+ export declare function createMAv2Base<TSigner extends SmartAccountSigner = SmartAccountSigner>(config: CreateMAV2BaseParams): CreateMAV2BaseReturnType<TSigner>;
@@ -5,12 +5,17 @@ import { modularAccountAbi } from "../../abis/modularAccountAbi.js";
5
5
  import { serializeModuleEntity } from "../../actions/common/utils.js";
6
6
  import { nativeSMASigner } from "../nativeSMASigner.js";
7
7
  import { singleSignerMessageSigner } from "../../modules/single-signer-validation/signer.js";
8
+ import { webauthnSigningFunctions } from "../../modules/webauthn-validation/signingMethods.js";
8
9
  export const executeUserOpSelector = "0x8DD7712F";
9
10
  export async function createMAv2Base(config) {
10
- let { transport, chain, signer, entryPoint = getEntryPoint(chain, { version: "0.7.0" }), signerEntity = {
11
+ let { transport, chain, entryPoint = getEntryPoint(chain, { version: "0.7.0" }), signerEntity = {
11
12
  isGlobalValidation: true,
12
13
  entityId: DEFAULT_OWNER_ENTITY_ID,
13
14
  }, signerEntity: { isGlobalValidation = true, entityId = DEFAULT_OWNER_ENTITY_ID, } = {}, accountAddress, deferredAction, ...remainingToSmartContractAccountParams } = config;
15
+ const signer = "signer" in config ? config.signer : undefined;
16
+ const credential = "credential" in config ? config.credential : undefined;
17
+ const getFn = "getFn" in config ? config.getFn : undefined;
18
+ const rpId = "rpId" in config ? config.rpId : undefined;
14
19
  if (entityId > Number(maxUint32)) {
15
20
  throw new InvalidEntityIdError(entityId);
16
21
  }
@@ -138,10 +143,23 @@ export async function createMAv2Base(config) {
138
143
  encodeExecute,
139
144
  encodeBatchExecute,
140
145
  getNonce,
141
- ...(entityId === DEFAULT_OWNER_ENTITY_ID
142
- ? nativeSMASigner(signer, chain, accountAddress, deferredActionData)
143
- : singleSignerMessageSigner(signer, chain, accountAddress, entityId, deferredActionData)),
146
+ ...(signer
147
+ ? entityId === DEFAULT_OWNER_ENTITY_ID
148
+ ? nativeSMASigner(signer, chain, accountAddress, deferredActionData)
149
+ : singleSignerMessageSigner(signer, chain, accountAddress, entityId, deferredActionData)
150
+ : webauthnSigningFunctions(
151
+ // credential required for webauthn mode is checked at modularAccountV2 creation level
152
+ credential, getFn, rpId, chain, accountAddress, entityId, deferredActionData)),
144
153
  });
154
+ if (!signer) {
155
+ return {
156
+ ...baseAccount,
157
+ signerEntity,
158
+ getExecutionData,
159
+ getValidationData,
160
+ encodeCallData,
161
+ }; // TO DO: figure out when this breaks! we shouldn't have to cast
162
+ }
145
163
  return {
146
164
  ...baseAccount,
147
165
  getSigner: () => signer,
@@ -149,6 +167,6 @@ export async function createMAv2Base(config) {
149
167
  getExecutionData,
150
168
  getValidationData,
151
169
  encodeCallData,
152
- };
170
+ }; // TO DO: figure out when this breaks! we shouldn't have to cast
153
171
  }
154
172
  //# sourceMappingURL=modularAccountV2Base.js.map
@@ -1 +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,0BAA0B,EAC1B,sBAAsB,GAKvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,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;AAmEvD,MAAM,CAAC,KAAK,UAAU,cAAc,CAElC,MAAqC;IACrC,IAAI,EACF,SAAS,EACT,KAAK,EACL,MAAM,EACN,UAAU,GAAG,aAAa,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EACvD,YAAY,GAAG;QACb,kBAAkB,EAAE,IAAI;QACxB,QAAQ,EAAE,uBAAuB;KAClC,EACD,YAAY,EAAE,EACZ,kBAAkB,GAAG,IAAI,EACzB,QAAQ,GAAG,uBAAuB,GACnC,GAAG,EAAE,EACN,cAAc,EACd,cAAc,EACd,GAAG,qCAAqC,EACzC,GAAG,MAAM,CAAC;IAEX,IAAI,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,EAAE,CAA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CAAC;YAC3B,sBAAsB,GAAG,KAAK,CAAC,CAAC,+BAA+B;YAC/D,OAAO,SAAS,CAAC,CAAC,qBAAqB,EAAE,QAAQ,CAAC,CAAC,CAAC;QACtD,CAAC;QACD,IAAI,cAAc,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;YACzC,OAAO,SAAS,CAAC,CAAC,qBAAqB,EAAE,QAAQ,CAAC,CAAC,CAAC;QACtD,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,MAAM,sBAAsB,CAAC;QAC/C,GAAG,qCAAqC;QACxC,SAAS;QACT,KAAK;QACL,UAAU;QACV,cAAc;QACd,aAAa;QACb,kBAAkB;QAClB,QAAQ;QACR,GAAG,CAAC,QAAQ,KAAK,uBAAuB;YACtC,CAAC,CAAC,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,kBAAkB,CAAC;YACpE,CAAC,CAAC,yBAAyB,CACvB,MAAM,EACN,KAAK,EACL,cAAc,EACd,QAAQ,EACR,kBAAkB,CACnB,CAAC;KACP,CAAC,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 InvalidDeferredActionNonce,\n toSmartContractAccount,\n type AccountOp,\n type SmartAccountSigner,\n type SmartContractAccountWithSigner,\n type ToSmartContractAccountParams,\n} from \"@aa-sdk/core\";\nimport { DEFAULT_OWNER_ENTITY_ID, parseDeferredAction } 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 | \"prepareSign\"\n | \"formatSign\"\n> & {\n signer: TSigner;\n signerEntity?: SignerEntity;\n accountAddress: Address;\n deferredAction?: Hex;\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 let {\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 deferredAction,\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 entryPointContract = getContract({\n address: entryPoint.address,\n abi: entryPoint.abi,\n client,\n });\n\n // These default values signal that we should not use the set deferred action nonce\n let nonce: bigint | undefined;\n let deferredActionData: Hex | undefined;\n let hasAssociatedExecHooks: boolean = false;\n\n if (deferredAction) {\n let deferredActionNonce: bigint = 0n;\n // We always update entity id and isGlobalValidation to the deferred action value since the client could be used to send multiple calls\n ({\n entityId,\n isGlobalValidation,\n nonce: deferredActionNonce,\n } = parseDeferredAction(deferredAction));\n\n // Set these values if the deferred action has not been consumed. We check this with the EP\n const nextNonceForDeferredAction: bigint =\n (await entryPointContract.read.getNonce([\n accountAddress,\n deferredActionNonce >> 64n,\n ])) as bigint;\n\n if (deferredActionNonce === nextNonceForDeferredAction) {\n ({ nonce, deferredActionData, hasAssociatedExecHooks } =\n parseDeferredAction(deferredAction));\n } else if (deferredActionNonce > nextNonceForDeferredAction) {\n // if nonce is greater than the next nonce, its invalid, so we throw\n throw new InvalidDeferredActionNonce();\n }\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\n const getNonce = async (nonceKey: bigint = 0n): Promise<bigint> => {\n if (nonce) {\n const tempNonce = nonce;\n nonce = undefined; // set to falsy value once used\n return tempNonce;\n }\n\n if (nonceKey > maxUint152) {\n throw new InvalidNonceKeyError(nonceKey);\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 if (hasAssociatedExecHooks) {\n hasAssociatedExecHooks = false; // set to falsy value once used\n return concatHex([executeUserOpSelector, callData]);\n }\n if (validationData.executionHooks.length) {\n return concatHex([executeUserOpSelector, callData]);\n }\n return 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, deferredActionData)\n : singleSignerMessageSigner(\n signer,\n chain,\n accountAddress,\n entityId,\n deferredActionData,\n )),\n });\n\n return {\n ...baseAccount,\n getSigner: () => signer,\n signerEntity,\n getExecutionData,\n getValidationData,\n encodeCallData,\n };\n}\n"]}
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,0BAA0B,EAC1B,sBAAsB,GAMvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,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,OAAO,EAAE,wBAAwB,EAAE,MAAM,qDAAqD,CAAC;AAE/F,MAAM,CAAC,MAAM,qBAAqB,GAAQ,YAAY,CAAC;AAoGvD,MAAM,CAAC,KAAK,UAAU,cAAc,CAGlC,MAAoE;IAEpE,IAAI,EACF,SAAS,EACT,KAAK,EACL,UAAU,GAAG,aAAa,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EACvD,YAAY,GAAG;QACb,kBAAkB,EAAE,IAAI;QACxB,QAAQ,EAAE,uBAAuB;KAClC,EACD,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AAE,kBAAkB,CAAC;gBACpE,CAAC,CAAC,yBAAyB,CACvB,MAAM,EACN,KAAK,EACL,cAAc,EACd,QAAQ,EACR,kBAAkB,CACnB;YACL,CAAC,CAAC,wBAAwB;YACtB,sFAAsF;YACtF,UAAW,EACX,KAAK,EACL,IAAI,EACJ,KAAK,EACL,cAAc,EACd,QAAQ,EACR,kBAAkB,CACnB,CAAC;KACP,CAAC,CAAC;IAEH,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO;YACL,GAAG,WAAW;YACd,YAAY;YACZ,gBAAgB;YAChB,iBAAiB;YACjB,cAAc;SACa,CAAC,CAAC,gEAAgE;IACjG,CAAC;IAED,OAAO;QACL,GAAG,WAAW;QACd,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM;QACvB,YAAY;QACZ,gBAAgB;QAChB,iBAAiB;QACjB,cAAc;KACc,CAAC,CAAC,gEAAgE;AAClG,CAAC","sourcesContent":["import {\n createBundlerClient,\n getEntryPoint,\n InvalidEntityIdError,\n InvalidNonceKeyError,\n InvalidDeferredActionNonce,\n toSmartContractAccount,\n type AccountOp,\n type SmartAccountSigner,\n type SmartContractAccountWithSigner,\n type ToSmartContractAccountParams,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport { DEFAULT_OWNER_ENTITY_ID, parseDeferredAction } 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\";\nimport type { ToWebAuthnAccountParameters } from \"viem/account-abstraction\";\nimport { webauthnSigningFunctions } from \"../../modules/webauthn-validation/signingMethods.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 WebauthnModularAccountV2 = SmartContractAccount<\n \"ModularAccountV2\",\n \"0.7.0\"\n> & {\n params: ToWebAuthnAccountParameters;\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 | undefined =\n | SmartAccountSigner\n | undefined,\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 | \"prepareSign\"\n | \"formatSign\"\n> & {\n signer: TSigner;\n signerEntity?: SignerEntity;\n accountAddress: Address;\n deferredAction?: Hex;\n};\n\nexport type CreateWebauthnMAV2BaseParams = Omit<\n CreateMAV2BaseParams,\n \"signer\"\n> & {\n credential: ToWebAuthnAccountParameters[\"credential\"];\n getFn?: ToWebAuthnAccountParameters[\"getFn\"] | undefined;\n rpId?: ToWebAuthnAccountParameters[\"rpId\"] | undefined;\n};\n\nexport type CreateMAV2BaseReturnType<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n> = Promise<ModularAccountV2<TSigner>>;\n\n// function overload\nexport async function createMAv2Base(\n config: CreateWebauthnMAV2BaseParams,\n): Promise<WebauthnModularAccountV2>;\n\nexport async function createMAv2Base<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n>(config: CreateMAV2BaseParams): CreateMAV2BaseReturnType<TSigner>;\n\nexport async function createMAv2Base<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n>(\n config: CreateMAV2BaseParams<TSigner> | CreateWebauthnMAV2BaseParams,\n): Promise<WebauthnModularAccountV2 | ModularAccountV2<TSigner>> {\n let {\n transport,\n chain,\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 deferredAction,\n ...remainingToSmartContractAccountParams\n } = config;\n\n const signer = \"signer\" in config ? config.signer : undefined;\n const credential = \"credential\" in config ? config.credential : undefined;\n const getFn = \"getFn\" in config ? config.getFn : undefined;\n const rpId = \"rpId\" in config ? config.rpId : undefined;\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 entryPointContract = getContract({\n address: entryPoint.address,\n abi: entryPoint.abi,\n client,\n });\n\n // These default values signal that we should not use the set deferred action nonce\n let nonce: bigint | undefined;\n let deferredActionData: Hex | undefined;\n let hasAssociatedExecHooks: boolean = false;\n\n if (deferredAction) {\n let deferredActionNonce: bigint = 0n;\n // We always update entity id and isGlobalValidation to the deferred action value since the client could be used to send multiple calls\n ({\n entityId,\n isGlobalValidation,\n nonce: deferredActionNonce,\n } = parseDeferredAction(deferredAction));\n\n // Set these values if the deferred action has not been consumed. We check this with the EP\n const nextNonceForDeferredAction: bigint =\n (await entryPointContract.read.getNonce([\n accountAddress,\n deferredActionNonce >> 64n,\n ])) as bigint;\n\n if (deferredActionNonce === nextNonceForDeferredAction) {\n ({ nonce, deferredActionData, hasAssociatedExecHooks } =\n parseDeferredAction(deferredAction));\n } else if (deferredActionNonce > nextNonceForDeferredAction) {\n // if nonce is greater than the next nonce, its invalid, so we throw\n throw new InvalidDeferredActionNonce();\n }\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\n const getNonce = async (nonceKey: bigint = 0n): Promise<bigint> => {\n if (nonce) {\n const tempNonce = nonce;\n nonce = undefined; // set to falsy value once used\n return tempNonce;\n }\n\n if (nonceKey > maxUint152) {\n throw new InvalidNonceKeyError(nonceKey);\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 if (hasAssociatedExecHooks) {\n hasAssociatedExecHooks = false; // set to falsy value once used\n return concatHex([executeUserOpSelector, callData]);\n }\n if (validationData.executionHooks.length) {\n return concatHex([executeUserOpSelector, callData]);\n }\n return 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 ...(signer\n ? entityId === DEFAULT_OWNER_ENTITY_ID\n ? nativeSMASigner(signer, chain, accountAddress, deferredActionData)\n : singleSignerMessageSigner(\n signer,\n chain,\n accountAddress,\n entityId,\n deferredActionData,\n )\n : webauthnSigningFunctions(\n // credential required for webauthn mode is checked at modularAccountV2 creation level\n credential!,\n getFn,\n rpId,\n chain,\n accountAddress,\n entityId,\n deferredActionData,\n )),\n });\n\n if (!signer) {\n return {\n ...baseAccount,\n signerEntity,\n getExecutionData,\n getValidationData,\n encodeCallData,\n } as WebauthnModularAccountV2; // TO DO: figure out when this breaks! we shouldn't have to cast\n }\n\n return {\n ...baseAccount,\n getSigner: () => signer,\n signerEntity,\n getExecutionData,\n getValidationData,\n encodeCallData,\n } as ModularAccountV2<TSigner>; // TO DO: figure out when this breaks! we shouldn't have to cast\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import type { EntryPointDef, SmartAccountSigner, ToSmartContractAccountParams } from "@aa-sdk/core";
2
2
  import { type Address, type Chain, type Hex, type Transport } from "viem";
3
- import { type SignerEntity, type ModularAccountV2 } from "./common/modularAccountV2Base.js";
3
+ import { type SignerEntity, type ModularAccountV2, type WebauthnModularAccountV2 } from "./common/modularAccountV2Base.js";
4
+ import type { ToWebAuthnAccountParameters } from "viem/account-abstraction";
4
5
  export type CreateModularAccountV2Params<TTransport extends Transport = Transport, TSigner extends SmartAccountSigner = SmartAccountSigner> = (Pick<ToSmartContractAccountParams<"ModularAccountV2", TTransport, Chain, "0.7.0">, "transport" | "chain" | "accountAddress"> & {
5
6
  signer: TSigner;
6
7
  entryPoint?: EntryPointDef<"0.7.0", Chain>;
@@ -15,4 +16,17 @@ export type CreateModularAccountV2Params<TTransport extends Transport = Transpor
15
16
  } | {
16
17
  mode: "7702";
17
18
  });
19
+ export type CreateWebauthnModularAccountV2Params<TTransport extends Transport = Transport> = Pick<ToSmartContractAccountParams<"ModularAccountV2", TTransport, Chain, "0.7.0">, "transport" | "chain" | "accountAddress"> & {
20
+ mode: "webauthn";
21
+ credential: ToWebAuthnAccountParameters["credential"];
22
+ getFn?: ToWebAuthnAccountParameters["getFn"] | undefined;
23
+ rpId?: ToWebAuthnAccountParameters["rpId"] | undefined;
24
+ entryPoint?: EntryPointDef<"0.7.0", Chain>;
25
+ deferredAction?: Hex;
26
+ signerEntity?: SignerEntity;
27
+ salt?: bigint;
28
+ factoryAddress?: Address;
29
+ initCode?: Hex;
30
+ };
18
31
  export declare function createModularAccountV2<TTransport extends Transport = Transport, TSigner extends SmartAccountSigner = SmartAccountSigner>(config: CreateModularAccountV2Params<TTransport, TSigner>): Promise<ModularAccountV2<TSigner>>;
32
+ export declare function createModularAccountV2<TTransport extends Transport = Transport>(config: CreateWebauthnModularAccountV2Params<TTransport>): Promise<WebauthnModularAccountV2>;
@@ -1,10 +1,12 @@
1
- import { getEntryPoint, EntityIdOverrideError, InvalidModularAccountV2Mode, } from "@aa-sdk/core";
1
+ import { getEntryPoint, EntityIdOverrideError, InvalidModularAccountV2Mode, createBundlerClient, getAccountAddress, } from "@aa-sdk/core";
2
2
  import { concatHex, encodeFunctionData, } from "viem";
3
3
  import { accountFactoryAbi } from "../abis/accountFactoryAbi.js";
4
4
  import { getDefaultMAV2FactoryAddress, getDefaultSMAV2BytecodeAddress, } from "../utils.js";
5
5
  import { createMAv2Base, } from "./common/modularAccountV2Base.js";
6
6
  import { DEFAULT_OWNER_ENTITY_ID } from "../utils.js";
7
7
  import { predictModularAccountV2Address } from "./predictAddress.js";
8
+ import { parsePublicKey } from "webauthn-p256";
9
+ import { SignerRequiredFor7702Error, SignerRequiredForDefaultError, WebauthnCredentialsRequiredError, } from "../errors.js";
8
10
  /**
9
11
  * Creates a ModularAccount V2 account, with the mode depending on the provided "mode" field.
10
12
  * Possible modes include: "default", which is SMA Bytecode, and "7702", which is SMA 7702.
@@ -34,20 +36,60 @@ import { predictModularAccountV2Address } from "./predictAddress.js";
34
36
  * });
35
37
  * ```
36
38
  *
37
- * @param {CreateModularAccountV2Params} config Configuration parameters for creating a Modular Account V2.
38
- * @returns {Promise<ModularAccountV2>} A promise that resolves to an `ModularAccountV2` providing methods for nonce retrieval, transaction execution, and more.
39
+ * @param {CreateModularAccountV2Params | CreateWebauthnModularAccountV2Params} config Configuration parameters for creating a Modular Account V2.
40
+ * @returns {Promise<ModularAccountV2 | WebauthnModularAccountV2>} A promise that resolves to an `ModularAccountV2` providing methods for nonce retrieval, transaction execution, and more.
39
41
  */
40
42
  export async function createModularAccountV2(config) {
41
- const { transport, chain, signer, accountAddress: _accountAddress, entryPoint = getEntryPoint(chain, { version: "0.7.0" }), signerEntity = {
43
+ const { transport, chain, accountAddress: _accountAddress, entryPoint = getEntryPoint(chain, { version: "0.7.0" }), signerEntity = {
42
44
  isGlobalValidation: true,
43
45
  entityId: DEFAULT_OWNER_ENTITY_ID,
44
46
  }, signerEntity: { entityId = DEFAULT_OWNER_ENTITY_ID } = {}, deferredAction, } = config;
47
+ const signer = "signer" in config ? config.signer : undefined;
48
+ const credential = "credential" in config ? config.credential : undefined;
49
+ const getFn = "getFn" in config ? config.getFn : undefined;
50
+ const rpId = "rpId" in config ? config.rpId : undefined;
51
+ const client = createBundlerClient({
52
+ transport,
53
+ chain,
54
+ });
45
55
  const accountFunctions = await (async () => {
46
56
  switch (config.mode) {
57
+ case "webauthn": {
58
+ if (!credential)
59
+ throw new WebauthnCredentialsRequiredError();
60
+ const publicKey = credential.publicKey;
61
+ const { x, y } = parsePublicKey(publicKey);
62
+ const { salt = 0n, factoryAddress = getDefaultMAV2FactoryAddress(chain), initCode, } = config;
63
+ const getAccountInitCode = async () => {
64
+ if (initCode) {
65
+ return initCode;
66
+ }
67
+ return concatHex([
68
+ factoryAddress,
69
+ encodeFunctionData({
70
+ abi: accountFactoryAbi,
71
+ functionName: "createWebAuthnAccount",
72
+ args: [x, y, salt, entityId],
73
+ }),
74
+ ]);
75
+ };
76
+ const accountAddress = await getAccountAddress({
77
+ client,
78
+ entryPoint,
79
+ accountAddress: _accountAddress,
80
+ getAccountInitCode,
81
+ });
82
+ return {
83
+ getAccountInitCode,
84
+ accountAddress,
85
+ };
86
+ }
47
87
  case "7702": {
48
88
  const getAccountInitCode = async () => {
49
89
  return "0x";
50
90
  };
91
+ if (!signer)
92
+ throw new SignerRequiredFor7702Error();
51
93
  const signerAddress = await signer.getAddress();
52
94
  const accountAddress = _accountAddress ?? signerAddress;
53
95
  if (entityId === DEFAULT_OWNER_ENTITY_ID &&
@@ -64,6 +106,8 @@ export async function createModularAccountV2(config) {
64
106
  }
65
107
  case "default":
66
108
  case undefined: {
109
+ if (!signer)
110
+ throw new SignerRequiredForDefaultError();
67
111
  const { salt = 0n, factoryAddress = getDefaultMAV2FactoryAddress(chain), implementationAddress = getDefaultSMAV2BytecodeAddress(chain), initCode, } = config;
68
112
  const signerAddress = await signer.getAddress();
69
113
  const getAccountInitCode = async () => {
@@ -75,7 +119,7 @@ export async function createModularAccountV2(config) {
75
119
  encodeFunctionData({
76
120
  abi: accountFactoryAbi,
77
121
  functionName: "createSemiModularAccount",
78
- args: [signerAddress, salt],
122
+ args: [await signer.getAddress(), salt],
79
123
  }),
80
124
  ]);
81
125
  };
@@ -96,8 +140,24 @@ export async function createModularAccountV2(config) {
96
140
  assertNever(config);
97
141
  }
98
142
  })();
99
- return createMAv2Base({
100
- source: "ModularAccountV2",
143
+ if (!signer) {
144
+ if (!credential)
145
+ throw new WebauthnCredentialsRequiredError();
146
+ return await createMAv2Base({
147
+ source: "ModularAccountV2", // TO DO: remove need to pass in source?
148
+ transport,
149
+ chain,
150
+ entryPoint,
151
+ signerEntity,
152
+ deferredAction,
153
+ credential,
154
+ getFn,
155
+ rpId,
156
+ ...accountFunctions,
157
+ });
158
+ }
159
+ return await createMAv2Base({
160
+ source: "ModularAccountV2", // TO DO: remove need to pass in source?
101
161
  transport,
102
162
  chain,
103
163
  signer,
@@ -1 +1 @@
1
- {"version":3,"file":"modularAccountV2.js","sourceRoot":"","sources":["../../../../../src/ma-v2/account/modularAccountV2.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,aAAa,EACb,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,EACL,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,aAAa,CAAC;AACrB,OAAO,EAGL,cAAc,GACf,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AAkCrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,MAAoC;IAEpC,MAAM,EACJ,SAAS,E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MAAM,kBAAkB,GAAG,KAAK,IAAI,EAAE;oBACpC,IAAI,QAAQ,EAAE,CAAC;wBACb,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,aAAa,EAAE,IAAI,CAAC;yBAC5B,CAAC;qBACH,CAAC,CAAC;gBACL,CAAC,CAAC;gBAEF,MAAM,cAAc,GAClB,eAAe;oBACf,8BAA8B,CAAC;wBAC7B,cAAc;wBACd,qBAAqB;wBACrB,IAAI;wBACJ,IAAI,EAAE,KAAK;wBACX,YAAY,EAAE,aAAa;qBAC5B,CAAC,CAAC;gBAEL,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,cAAc;QACd,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 getEntryPoint,\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 {\n getDefaultMAV2FactoryAddress,\n getDefaultSMAV2BytecodeAddress,\n} 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\";\nimport { predictModularAccountV2Address } from \"./predictAddress.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 deferredAction?: Hex;\n signerEntity?: SignerEntity;\n}) &\n (\n | {\n mode?: \"default\";\n salt?: bigint;\n factoryAddress?: Address;\n implementationAddress?: 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 deferredAction,\n } = config;\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 implementationAddress = getDefaultSMAV2BytecodeAddress(chain),\n initCode,\n } = config;\n\n const signerAddress = await signer.getAddress();\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: [signerAddress, salt],\n }),\n ]);\n };\n\n const accountAddress =\n _accountAddress ??\n predictModularAccountV2Address({\n factoryAddress,\n implementationAddress,\n salt,\n type: \"SMA\",\n ownerAddress: signerAddress,\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 deferredAction,\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"]}
1
+ {"version":3,"file":"modularAccountV2.js","sourceRoot":"","sources":["../../../../../src/ma-v2/account/modularAccountV2.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,2BAA2B,EAC3B,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,SAAS,EACT,kBAAkB,GAKnB,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,aAAa,CAAC;AACrB,OAAO,EAGL,cAAc,GAEf,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AAErE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,EAC7B,gCAAgC,GACjC,MAAM,cAAc,CAAC;AA0DtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAI1C,MAEoD;IAEpD,MAAM,EACJ,SAAS,EACT,KAAK,EACL,cAAc,EAAE,eAAe,EAC/B,UAAU,GAAG,aAAa,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EACvD,YAAY,GAAG;QACb,kBAAkB,EAAE,IAAI;QACxB,QAAQ,EAAE,uBAAuB;KAClC,EACD,YAAY,EAAE,EAAE,QAAQ,GAAG,uBAAuB,EAAE,GAAG,EAAE,EACzD,cAAc,GACf,GAAG,MAAM,CAAC;IAEX,MAAM,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AAC;AAC1C,CAAC","sourcesContent":["import type {\n EntryPointDef,\n SmartAccountSigner,\n ToSmartContractAccountParams,\n} from \"@aa-sdk/core\";\nimport {\n getEntryPoint,\n EntityIdOverrideError,\n InvalidModularAccountV2Mode,\n createBundlerClient,\n getAccountAddress,\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 {\n getDefaultMAV2FactoryAddress,\n getDefaultSMAV2BytecodeAddress,\n} from \"../utils.js\";\nimport {\n type SignerEntity,\n type ModularAccountV2,\n createMAv2Base,\n type WebauthnModularAccountV2,\n} from \"./common/modularAccountV2Base.js\";\nimport { DEFAULT_OWNER_ENTITY_ID } from \"../utils.js\";\nimport { predictModularAccountV2Address } from \"./predictAddress.js\";\nimport type { ToWebAuthnAccountParameters } from \"viem/account-abstraction\";\nimport { parsePublicKey } from \"webauthn-p256\";\nimport {\n SignerRequiredFor7702Error,\n SignerRequiredForDefaultError,\n WebauthnCredentialsRequiredError,\n} from \"../errors.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 deferredAction?: Hex;\n signerEntity?: SignerEntity;\n}) &\n (\n | {\n mode?: \"default\";\n salt?: bigint;\n factoryAddress?: Address;\n implementationAddress?: Address;\n initCode?: Hex;\n }\n | {\n mode: \"7702\";\n }\n );\n\nexport type CreateWebauthnModularAccountV2Params<\n TTransport extends Transport = Transport,\n> = Pick<\n ToSmartContractAccountParams<\"ModularAccountV2\", TTransport, Chain, \"0.7.0\">,\n \"transport\" | \"chain\" | \"accountAddress\"\n> & {\n mode: \"webauthn\";\n credential: ToWebAuthnAccountParameters[\"credential\"];\n getFn?: ToWebAuthnAccountParameters[\"getFn\"] | undefined;\n rpId?: ToWebAuthnAccountParameters[\"rpId\"] | undefined;\n entryPoint?: EntryPointDef<\"0.7.0\", Chain>;\n deferredAction?: Hex;\n signerEntity?: SignerEntity;\n salt?: bigint;\n factoryAddress?: Address;\n initCode?: Hex;\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\nexport async function createModularAccountV2<\n TTransport extends Transport = Transport,\n>(\n config: CreateWebauthnModularAccountV2Params<TTransport>,\n): Promise<WebauthnModularAccountV2>;\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 | CreateWebauthnModularAccountV2Params} config Configuration parameters for creating a Modular Account V2.\n * @returns {Promise<ModularAccountV2 | WebauthnModularAccountV2>} A promise that resolves to an `ModularAccountV2` providing methods for nonce retrieval, transaction execution, and more.\n */\nexport async function createModularAccountV2<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n>(\n config:\n | CreateModularAccountV2Params<TTransport, TSigner>\n | CreateWebauthnModularAccountV2Params<TTransport>,\n): Promise<ModularAccountV2<TSigner> | WebauthnModularAccountV2> {\n const {\n transport,\n chain,\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 deferredAction,\n } = config;\n\n const signer = \"signer\" in config ? config.signer : undefined;\n\n const credential = \"credential\" in config ? config.credential : undefined;\n\n const getFn = \"getFn\" in config ? config.getFn : undefined;\n\n const rpId = \"rpId\" in config ? config.rpId : undefined;\n\n const client = createBundlerClient({\n transport,\n chain,\n });\n\n const accountFunctions = await (async () => {\n switch (config.mode) {\n case \"webauthn\": {\n if (!credential) throw new WebauthnCredentialsRequiredError();\n const publicKey = credential.publicKey;\n const { x, y } = parsePublicKey(publicKey);\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: \"createWebAuthnAccount\",\n args: [x, y, salt, entityId],\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 case \"7702\": {\n const getAccountInitCode = async (): Promise<Hex> => {\n return \"0x\";\n };\n if (!signer) throw new SignerRequiredFor7702Error();\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 if (!signer) throw new SignerRequiredForDefaultError();\n const {\n salt = 0n,\n factoryAddress = getDefaultMAV2FactoryAddress(chain),\n implementationAddress = getDefaultSMAV2BytecodeAddress(chain),\n initCode,\n } = config;\n\n const signerAddress = await signer.getAddress();\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 =\n _accountAddress ??\n predictModularAccountV2Address({\n factoryAddress,\n implementationAddress,\n salt,\n type: \"SMA\",\n ownerAddress: signerAddress,\n });\n\n return {\n getAccountInitCode,\n accountAddress,\n };\n }\n default:\n assertNever(config);\n }\n })();\n\n if (!signer) {\n if (!credential) throw new WebauthnCredentialsRequiredError();\n return await createMAv2Base({\n source: \"ModularAccountV2\", // TO DO: remove need to pass in source?\n transport,\n chain,\n entryPoint,\n signerEntity,\n deferredAction,\n credential,\n getFn,\n rpId,\n ...accountFunctions,\n });\n }\n\n return await createMAv2Base({\n source: \"ModularAccountV2\", // TO DO: remove need to pass in source?\n transport,\n chain,\n signer,\n entryPoint,\n signerEntity,\n deferredAction,\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"]}
@@ -1,14 +1,22 @@
1
- import { type SmartAccountClient, type SmartAccountSigner, type SmartAccountClientConfig, type NotType } from "@aa-sdk/core";
1
+ import { type SmartAccountClient, type SmartAccountClientConfig, type SmartAccountSigner } from "@aa-sdk/core";
2
2
  import { type Chain, type Transport } from "viem";
3
- import { type CreateModularAccountV2Params } from "../account/modularAccountV2.js";
4
- import { type AlchemySmartAccountClientConfig, type AlchemyTransport } from "@account-kit/infra";
3
+ import { type CreateModularAccountV2Params, type CreateWebauthnModularAccountV2Params } from "../account/modularAccountV2.js";
4
+ import { type AlchemySmartAccountClient, type AlchemySmartAccountClientConfig, type AlchemyTransport } from "@account-kit/infra";
5
5
  import type { LightAccount } from "../../light-account/accounts/account.js";
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">;
6
+ import type { ToWebAuthnAccountParameters } from "viem/account-abstraction";
7
+ import type { ModularAccountV2, WebauthnModularAccountV2 } from "../account/common/modularAccountV2Base.js";
8
+ export type ModularAccountV2Client<TSigner extends SmartAccountSigner = SmartAccountSigner, TChain extends Chain = Chain, TTransport extends Transport | AlchemyTransport = Transport> = TTransport extends AlchemyTransport ? AlchemySmartAccountClient<TChain, ModularAccountV2<TSigner>> : SmartAccountClient<TTransport, TChain, ModularAccountV2<TSigner>>;
9
+ export type WebauthnModularAccountV2Client<TChain extends Chain = Chain, TTransport extends Transport | AlchemyTransport = Transport> = TTransport extends AlchemyTransport ? AlchemySmartAccountClient<TChain, WebauthnModularAccountV2> : SmartAccountClient<TTransport, TChain, WebauthnModularAccountV2>;
10
+ export type CreateModularAccountV2ClientParams<TTransport extends Transport | AlchemyTransport = Transport, TChain extends Chain = Chain, TSigner extends SmartAccountSigner = SmartAccountSigner> = CreateModularAccountV2Params<TTransport, TSigner> & Omit<TTransport extends AlchemyTransport ? AlchemySmartAccountClientConfig<TChain> : SmartAccountClientConfig<TTransport, TChain>, "transport" | "account" | "chain">;
11
+ export type CreateWebauthnModularAccountV2ClientParams<TTransport extends Transport | AlchemyTransport = Transport, TChain extends Chain = Chain> = CreateWebauthnModularAccountV2Params<TTransport> & Omit<TTransport extends AlchemyTransport ? AlchemySmartAccountClientConfig<TChain> : SmartAccountClientConfig<TTransport, TChain>, "transport" | "account" | "chain"> & {
12
+ credential: ToWebAuthnAccountParameters["credential"];
13
+ getFn?: ToWebAuthnAccountParameters["getFn"];
14
+ rpId?: ToWebAuthnAccountParameters["rpId"];
15
+ };
9
16
  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"> & {
10
17
  paymasterAndData?: never;
11
18
  dummyPaymasterAndData?: never;
12
19
  };
13
20
  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>>;
21
+ export declare function createModularAccountV2Client<TTransport extends Transport = Transport, TChain extends Chain = Chain, TSigner extends SmartAccountSigner = SmartAccountSigner>(args: CreateModularAccountV2ClientParams<TTransport, TChain, TSigner>): Promise<ModularAccountV2Client<TSigner, TChain, TTransport>>;
22
+ export declare function createModularAccountV2Client<TTransport extends Transport = Transport, TChain extends Chain = Chain>(args: CreateWebauthnModularAccountV2ClientParams<TTransport, TChain>): Promise<WebauthnModularAccountV2Client<TChain, TTransport>>;
@@ -1,4 +1,4 @@
1
- import { createSmartAccountClient, default7702GasEstimator, default7702UserOpSigner, } from "@aa-sdk/core";
1
+ import { createSmartAccountClient, default7702GasEstimator, default7702UserOpSigner, webauthnGasEstimator, } from "@aa-sdk/core";
2
2
  import {} from "viem";
3
3
  import { createModularAccountV2, } from "../account/modularAccountV2.js";
4
4
  import { createAlchemySmartAccountClient, isAlchemyTransport, } from "@account-kit/infra";
@@ -35,13 +35,29 @@ import { createAlchemySmartAccountClient, isAlchemyTransport, } from "@account-k
35
35
  */
36
36
  export async function createModularAccountV2Client(config) {
37
37
  const { transport, chain } = config;
38
- const account = await createModularAccountV2(config);
39
- const middlewareToAppend = config.mode === "7702"
40
- ? {
41
- gasEstimator: default7702GasEstimator(config.gasEstimator),
42
- signUserOperation: default7702UserOpSigner(config.signUserOperation),
38
+ let account;
39
+ if (config.mode === "webauthn") {
40
+ account = await createModularAccountV2(config);
41
+ }
42
+ else {
43
+ account = await createModularAccountV2(config);
44
+ }
45
+ const middlewareToAppend = await (async () => {
46
+ switch (config.mode) {
47
+ case "7702":
48
+ return {
49
+ gasEstimator: default7702GasEstimator(config.gasEstimator),
50
+ signUserOperation: default7702UserOpSigner(config.signUserOperation),
51
+ };
52
+ case "webauthn":
53
+ return {
54
+ gasEstimator: webauthnGasEstimator(config.gasEstimator),
55
+ };
56
+ case "default":
57
+ default:
58
+ return {};
43
59
  }
44
- : {};
60
+ })();
45
61
  if (isAlchemyTransport(transport, chain)) {
46
62
  return createAlchemySmartAccountClient({
47
63
  ...config,
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../src/ma-v2/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAA8B,MAAM,MAAM,CAAC;AAElD,OAAO,EACL,sBAAsB,GAEvB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,+BAA+B,EAC/B,kBAAkB,GAInB,MAAM,oBAAoB,CAAC;AAsD5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,MAE6C;IAE7C,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IAEpC,MAAM,OAAO,GAAG,MAAM,sBAAsB,CAAC,MAAM,CAAC,CAAC;IAErD,MAAM,kBAAkB,GACtB,MAAM,CAAC,IAAI,KAAK,MAAM;QACpB,CAAC,CAAC;YACE,YAAY,EAAE,uBAAuB,CAAC,MAAM,CAAC,YAAY,CAAC;YAC1D,iBAAiB,EAAE,uBAAuB,CAAC,MAAM,CAAC,iBAAiB,CAAC;SACrE;QACH,CAAC,CAAC,EAAE,CAAC;IAET,IAAI,kBAAkB,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC;QACzC,OAAO,+BAA+B,CAAC;YACrC,GAAG,MAAM;YACT,SAAS;YACT,KAAK;YACL,OAAO;YACP,GAAG,kBAAkB;SACtB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,wBAAwB,CAAC;QAC9B,GAAG,MAAM;QACT,OAAO;QACP,GAAG,kBAAkB;KACtB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n type SmartAccountClient,\n type SmartAccountSigner,\n type SmartAccountClientConfig,\n type NotType,\n createSmartAccountClient,\n default7702GasEstimator,\n default7702UserOpSigner,\n} from \"@aa-sdk/core\";\nimport { type Chain, type Transport } from \"viem\";\n\nimport {\n createModularAccountV2,\n type CreateModularAccountV2Params,\n} from \"../account/modularAccountV2.js\";\n\nimport {\n createAlchemySmartAccountClient,\n isAlchemyTransport,\n type AlchemySmartAccountClient,\n type AlchemySmartAccountClientConfig,\n type AlchemyTransport,\n} from \"@account-kit/infra\";\nimport type { LightAccount } from \"../../light-account/accounts/account.js\";\n\nimport type { ModularAccountV2 } from \"../account/common/modularAccountV2Base.js\";\n\nexport type ModularAccountV2Client<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TChain extends Chain = Chain,\n TTransport extends Transport | AlchemyTransport = Transport,\n> = SmartAccountClient<TTransport, TChain, ModularAccountV2<TSigner>>;\n\nexport type CreateModularAccountV2ClientParams<\n TTransport extends Transport = Transport,\n TChain extends Chain = Chain,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n> = CreateModularAccountV2Params<TTransport, TSigner> &\n Omit<\n SmartAccountClientConfig<TTransport, TChain>,\n \"transport\" | \"account\" | \"chain\"\n >;\n\nexport type CreateModularAccountV2AlchemyClientParams<\n TTransport extends Transport = Transport,\n TChain extends Chain = Chain,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n> = Omit<\n CreateModularAccountV2ClientParams<TTransport, TChain, TSigner>,\n \"transport\"\n> &\n Omit<\n AlchemySmartAccountClientConfig<TChain, LightAccount<TSigner>>,\n \"account\"\n > & { paymasterAndData?: never; dummyPaymasterAndData?: never };\n\nexport function createModularAccountV2Client<\n TChain extends Chain = Chain,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n>(\n args: CreateModularAccountV2AlchemyClientParams<\n AlchemyTransport,\n TChain,\n TSigner\n >,\n): Promise<ModularAccountV2Client<TSigner, TChain, AlchemyTransport>>;\n\nexport function createModularAccountV2Client<\n TTransport extends Transport = Transport,\n TChain extends Chain = Chain,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n>(\n args: CreateModularAccountV2ClientParams<TTransport, TChain, TSigner> &\n NotType<TTransport, AlchemyTransport>,\n): Promise<ModularAccountV2Client<TSigner, TChain>>;\n\n/**\n * Creates a Modular Account V2 client using the provided configuration parameters.\n *\n * @example\n * ```ts twoslash\n * import { createModularAccountV2Client } 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 * const policyId = \"...\";\n *\n * const modularAccountV2Client = await createModularAccountV2Client({\n * chain,\n * signer,\n * transport,\n * policyId, // NOTE: you may only pass in a gas policy ID if you provide an Alchemy transport!\n * });\n * ```\n *\n * @param {CreateModularAccountV2ClientParams} config The configuration parameters required to create the Modular Account v2 account client\n * @returns {Promise<SmartAccountClient>} A promise that resolves to a `SmartAccountClient` instance\n */\nexport async function createModularAccountV2Client(\n config:\n | CreateModularAccountV2ClientParams\n | CreateModularAccountV2AlchemyClientParams,\n): Promise<SmartAccountClient | AlchemySmartAccountClient> {\n const { transport, chain } = config;\n\n const account = await createModularAccountV2(config);\n\n const middlewareToAppend =\n config.mode === \"7702\"\n ? {\n gasEstimator: default7702GasEstimator(config.gasEstimator),\n signUserOperation: default7702UserOpSigner(config.signUserOperation),\n }\n : {};\n\n if (isAlchemyTransport(transport, chain)) {\n return createAlchemySmartAccountClient({\n ...config,\n transport,\n chain,\n account,\n ...middlewareToAppend,\n });\n }\n\n return createSmartAccountClient({\n ...config,\n account,\n ...middlewareToAppend,\n });\n}\n"]}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../src/ma-v2/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,oBAAoB,GAIrB,MAAM,cAAc,CAAC;AACtB,OAAO,EAA8B,MAAM,MAAM,CAAC;AAElD,OAAO,EACL,sBAAsB,GAGvB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,+BAA+B,EAC/B,kBAAkB,GAInB,MAAM,oBAAoB,CAAC;AAyF5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,MAG6C;IAE7C,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IAEpC,IAAI,OAAO,CAAC;IAEZ,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/B,OAAO,GAAG,MAAM,sBAAsB,CACpC,MAAyD,CAC1D,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,MAAM,sBAAsB,CACpC,MAAsC,CACvC,CAAC;IACJ,CAAC;IAED,MAAM,kBAAkB,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE;QAC3C,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;YACpB,KAAK,MAAM;gBACT,OAAO;oBACL,YAAY,EAAE,uBAAuB,CAAC,MAAM,CAAC,YAAY,CAAC;oBAC1D,iBAAiB,EAAE,uBAAuB,CAAC,MAAM,CAAC,iBAAiB,CAAC;iBACrE,CAAC;YACJ,KAAK,UAAU;gBACb,OAAO;oBACL,YAAY,EAAE,oBAAoB,CAAC,MAAM,CAAC,YAAY,CAAC;iBACxD,CAAC;YACJ,KAAK,SAAS,CAAC;YACf;gBACE,OAAO,EAAE,CAAC;QACd,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;IAEL,IAAI,kBAAkB,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC;QACzC,OAAO,+BAA+B,CAAC;YACrC,GAAG,MAAM;YACT,SAAS;YACT,KAAK;YACL,OAAO;YACP,GAAG,kBAAkB;SACtB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,wBAAwB,CAAC;QAC9B,GAAG,MAAM;QACT,OAAO;QACP,GAAG,kBAAkB;KACtB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n createSmartAccountClient,\n default7702GasEstimator,\n default7702UserOpSigner,\n webauthnGasEstimator,\n type SmartAccountClient,\n type SmartAccountClientConfig,\n type SmartAccountSigner,\n} from \"@aa-sdk/core\";\nimport { type Chain, type Transport } from \"viem\";\n\nimport {\n createModularAccountV2,\n type CreateModularAccountV2Params,\n type CreateWebauthnModularAccountV2Params,\n} from \"../account/modularAccountV2.js\";\n\nimport {\n createAlchemySmartAccountClient,\n isAlchemyTransport,\n type AlchemySmartAccountClient,\n type AlchemySmartAccountClientConfig,\n type AlchemyTransport,\n} from \"@account-kit/infra\";\nimport type { LightAccount } from \"../../light-account/accounts/account.js\";\n\nimport type { ToWebAuthnAccountParameters } from \"viem/account-abstraction\";\nimport type {\n ModularAccountV2,\n WebauthnModularAccountV2,\n} from \"../account/common/modularAccountV2Base.js\";\n\nexport type ModularAccountV2Client<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TChain extends Chain = Chain,\n TTransport extends Transport | AlchemyTransport = Transport,\n> = TTransport extends AlchemyTransport\n ? AlchemySmartAccountClient<TChain, ModularAccountV2<TSigner>>\n : SmartAccountClient<TTransport, TChain, ModularAccountV2<TSigner>>;\n\nexport type WebauthnModularAccountV2Client<\n TChain extends Chain = Chain,\n TTransport extends Transport | AlchemyTransport = Transport,\n> = TTransport extends AlchemyTransport\n ? AlchemySmartAccountClient<TChain, WebauthnModularAccountV2>\n : SmartAccountClient<TTransport, TChain, WebauthnModularAccountV2>;\n\nexport type CreateModularAccountV2ClientParams<\n TTransport extends Transport | AlchemyTransport = Transport,\n TChain extends Chain = Chain,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n> = CreateModularAccountV2Params<TTransport, TSigner> &\n Omit<\n TTransport extends AlchemyTransport\n ? AlchemySmartAccountClientConfig<TChain>\n : SmartAccountClientConfig<TTransport, TChain>,\n \"transport\" | \"account\" | \"chain\"\n >;\n\nexport type CreateWebauthnModularAccountV2ClientParams<\n TTransport extends Transport | AlchemyTransport = Transport,\n TChain extends Chain = Chain,\n> = CreateWebauthnModularAccountV2Params<TTransport> &\n Omit<\n TTransport extends AlchemyTransport\n ? AlchemySmartAccountClientConfig<TChain>\n : SmartAccountClientConfig<TTransport, TChain>,\n \"transport\" | \"account\" | \"chain\"\n > & {\n credential: ToWebAuthnAccountParameters[\"credential\"];\n getFn?: ToWebAuthnAccountParameters[\"getFn\"];\n rpId?: ToWebAuthnAccountParameters[\"rpId\"];\n };\n\nexport type CreateModularAccountV2AlchemyClientParams<\n TTransport extends Transport = Transport,\n TChain extends Chain = Chain,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n> = Omit<\n CreateModularAccountV2ClientParams<TTransport, TChain, TSigner>,\n \"transport\"\n> &\n Omit<\n AlchemySmartAccountClientConfig<TChain, LightAccount<TSigner>>,\n \"account\"\n > & { paymasterAndData?: never; dummyPaymasterAndData?: never };\n\nexport function createModularAccountV2Client<\n TChain extends Chain = Chain,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n>(\n args: CreateModularAccountV2AlchemyClientParams<\n AlchemyTransport,\n TChain,\n TSigner\n >,\n): Promise<ModularAccountV2Client<TSigner, TChain, AlchemyTransport>>;\n\nexport function createModularAccountV2Client<\n TTransport extends Transport = Transport,\n TChain extends Chain = Chain,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n>(\n args: CreateModularAccountV2ClientParams<TTransport, TChain, TSigner>,\n): Promise<ModularAccountV2Client<TSigner, TChain, TTransport>>;\n\nexport function createModularAccountV2Client<\n TTransport extends Transport = Transport,\n TChain extends Chain = Chain,\n>(\n args: CreateWebauthnModularAccountV2ClientParams<TTransport, TChain>,\n): Promise<WebauthnModularAccountV2Client<TChain, TTransport>>;\n/**\n * Creates a Modular Account V2 client using the provided configuration parameters.\n *\n * @example\n * ```ts twoslash\n * import { createModularAccountV2Client } 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 * const policyId = \"...\";\n *\n * const modularAccountV2Client = await createModularAccountV2Client({\n * chain,\n * signer,\n * transport,\n * policyId, // NOTE: you may only pass in a gas policy ID if you provide an Alchemy transport!\n * });\n * ```\n *\n * @param {CreateModularAccountV2ClientParams} config The configuration parameters required to create the Modular Account v2 account client\n * @returns {Promise<SmartAccountClient>} A promise that resolves to a `SmartAccountClient` instance\n */\nexport async function createModularAccountV2Client(\n config:\n | CreateModularAccountV2ClientParams\n | CreateWebauthnModularAccountV2ClientParams\n | CreateModularAccountV2AlchemyClientParams,\n): Promise<SmartAccountClient | AlchemySmartAccountClient> {\n const { transport, chain } = config;\n\n let account;\n\n if (config.mode === \"webauthn\") {\n account = await createModularAccountV2(\n config as CreateWebauthnModularAccountV2Params<Transport>,\n );\n } else {\n account = await createModularAccountV2(\n config as CreateModularAccountV2Params,\n );\n }\n\n const middlewareToAppend = await (async () => {\n switch (config.mode) {\n case \"7702\":\n return {\n gasEstimator: default7702GasEstimator(config.gasEstimator),\n signUserOperation: default7702UserOpSigner(config.signUserOperation),\n };\n case \"webauthn\":\n return {\n gasEstimator: webauthnGasEstimator(config.gasEstimator),\n };\n case \"default\":\n default:\n return {};\n }\n })();\n\n if (isAlchemyTransport(transport, chain)) {\n return createAlchemySmartAccountClient({\n ...config,\n transport,\n chain,\n account,\n ...middlewareToAppend,\n });\n }\n\n return createSmartAccountClient({\n ...config,\n account,\n ...middlewareToAppend,\n });\n}\n"]}
@@ -0,0 +1,22 @@
1
+ import { BaseError } from "@aa-sdk/core";
2
+ /**
3
+ * Error when Webauthn credentials are not passed to Webauthn Modular Account V2
4
+ */
5
+ export declare class WebauthnCredentialsRequiredError extends BaseError {
6
+ name: string;
7
+ constructor();
8
+ }
9
+ /**
10
+ * Error when a signer is not passed to 7702 version of Modular Account V2
11
+ */
12
+ export declare class SignerRequiredFor7702Error extends BaseError {
13
+ name: string;
14
+ constructor();
15
+ }
16
+ /**
17
+ * Error when a signer is not passed to default Modular Account V2
18
+ */
19
+ export declare class SignerRequiredForDefaultError extends BaseError {
20
+ name: string;
21
+ constructor();
22
+ }
@@ -0,0 +1,44 @@
1
+ import { BaseError } from "@aa-sdk/core";
2
+ /**
3
+ * Error when Webauthn credentials are not passed to Webauthn Modular Account V2
4
+ */
5
+ export class WebauthnCredentialsRequiredError extends BaseError {
6
+ constructor() {
7
+ super("Webauthn credentials are required to create a Webauthn Modular Account V2");
8
+ Object.defineProperty(this, "name", {
9
+ enumerable: true,
10
+ configurable: true,
11
+ writable: true,
12
+ value: "WebauthnCredentialsRequiredError"
13
+ });
14
+ }
15
+ }
16
+ /**
17
+ * Error when a signer is not passed to 7702 version of Modular Account V2
18
+ */
19
+ export class SignerRequiredFor7702Error extends BaseError {
20
+ constructor() {
21
+ super("A signer is required to create a 7702 Modular Account V2");
22
+ Object.defineProperty(this, "name", {
23
+ enumerable: true,
24
+ configurable: true,
25
+ writable: true,
26
+ value: "SignerRequiredFor7702Error"
27
+ });
28
+ }
29
+ }
30
+ /**
31
+ * Error when a signer is not passed to default Modular Account V2
32
+ */
33
+ export class SignerRequiredForDefaultError extends BaseError {
34
+ constructor() {
35
+ super("A signer is required to create a default Modular Account V2");
36
+ Object.defineProperty(this, "name", {
37
+ enumerable: true,
38
+ configurable: true,
39
+ writable: true,
40
+ value: "SignerRequiredForDefaultError"
41
+ });
42
+ }
43
+ }
44
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../src/ma-v2/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC;;GAEG;AACH,MAAM,OAAO,gCAAiC,SAAQ,SAAS;IAE7D;QACE,KAAK,CACH,2EAA2E,CAC5E,CAAC;QAJK;;;;mBAAO,kCAAkC;WAAC;IAKnD,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,SAAS;IAEvD;QACE,KAAK,CAAC,0DAA0D,CAAC,CAAC;QAF3D;;;;mBAAO,4BAA4B;WAAC;IAG7C,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,6BAA8B,SAAQ,SAAS;IAE1D;QACE,KAAK,CAAC,6DAA6D,CAAC,CAAC;QAF9D;;;;mBAAO,+BAA+B;WAAC;IAGhD,CAAC;CACF","sourcesContent":["import { BaseError } from \"@aa-sdk/core\";\n\n/**\n * Error when Webauthn credentials are not passed to Webauthn Modular Account V2\n */\nexport class WebauthnCredentialsRequiredError extends BaseError {\n override name = \"WebauthnCredentialsRequiredError\";\n constructor() {\n super(\n \"Webauthn credentials are required to create a Webauthn Modular Account V2\",\n );\n }\n}\n\n/**\n * Error when a signer is not passed to 7702 version of Modular Account V2\n */\nexport class SignerRequiredFor7702Error extends BaseError {\n override name = \"SignerRequiredFor7702Error\";\n constructor() {\n super(\"A signer is required to create a 7702 Modular Account V2\");\n }\n}\n\n/**\n * Error when a signer is not passed to default Modular Account V2\n */\nexport class SignerRequiredForDefaultError extends BaseError {\n override name = \"SignerRequiredForDefaultError\";\n constructor() {\n super(\"A signer is required to create a default Modular Account V2\");\n }\n}\n"]}
@@ -26,3 +26,4 @@ export { SingleSignerValidationModule } from "./modules/single-signer-validation
26
26
  export { timeRangeModuleAbi } from "./modules/time-range-module/abis/timeRangeModuleAbi.js";
27
27
  export { TimeRangeModule } from "./modules/time-range-module/module.js";
28
28
  export { webauthnValidationModuleAbi } from "./modules/webauthn-validation/abis/webauthnValidationAbi.js";
29
+ export { WebAuthnValidationModule } from "./modules/webauthn-validation/module.js";
@@ -23,4 +23,5 @@ export { SingleSignerValidationModule } from "./modules/single-signer-validation
23
23
  export { timeRangeModuleAbi } from "./modules/time-range-module/abis/timeRangeModuleAbi.js";
24
24
  export { TimeRangeModule } from "./modules/time-range-module/module.js";
25
25
  export { webauthnValidationModuleAbi } from "./modules/webauthn-validation/abis/webauthnValidationAbi.js";
26
+ export { WebAuthnValidationModule } from "./modules/webauthn-validation/module.js";
26
27
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ma-v2/index.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB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kBAAkB,EAAE,MAAM,wDAAwD,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,6DAA6D,CAAC","sourcesContent":["// ma v2 exports\nexport { accountFactoryAbi } from \"./abis/accountFactoryAbi.js\";\nexport { modularAccountAbi } from \"./abis/modularAccountAbi.js\";\nexport { semiModularAccountBytecodeAbi } from \"./abis/semiModularAccountBytecodeAbi.js\";\nexport { semiModularAccountStorageAbi } from \"./abis/semiModularAccountStorageAbi.js\";\n\nexport { nativeSMASigner } from \"./account/nativeSMASigner.js\";\n\nexport type {\n ModuleEntity,\n ValidationConfig,\n HookConfig,\n ValidationData,\n} from \"./actions/common/types.js\";\nexport { HookType } from \"./actions/common/types.js\";\nexport {\n serializeValidationConfig,\n serializeHookConfig,\n serializeModuleEntity,\n} from \"./actions/common/utils.js\";\nexport type * from \"./actions/install-validation/installValidation.js\";\nexport { installValidationActions } from \"./actions/install-validation/installValidation.js\";\nexport type * from \"./actions/deferralActions.js\";\nexport { deferralActions } from \"./actions/deferralActions.js\";\nexport type * from \"./permissionBuilder.js\";\nexport { PermissionBuilder, PermissionType } from \"./permissionBuilder.js\";\nexport * from \"./permissionBuilderErrors.js\";\n\nexport {\n getDefaultAllowlistModuleAddress,\n getDefaultNativeTokenLimitModuleAddress,\n getDefaultPaymasterGuardModuleAddress,\n getDefaultSingleSignerValidationModuleAddress,\n getDefaultTimeRangeModuleAddress,\n getDefaultWebauthnValidationModuleAddress,\n} from \"./modules/utils.js\";\nexport { buildFullNonceKey, buildDeferredActionDigest } from \"./utils.js\";\nexport { allowlistModuleAbi } from \"./modules/allowlist-module/abis/allowlistModuleAbi.js\";\nexport { AllowlistModule } from \"./modules/allowlist-module/module.js\";\nexport { nativeTokenLimitModuleAbi } from \"./modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.js\";\nexport { NativeTokenLimitModule } from \"./modules/native-token-limit-module/module.js\";\nexport { paymasterGuardModuleAbi } from \"./modules/paymaster-guard-module/abis/paymasterGuardModuleAbi.js\";\nexport { PaymasterGuardModule } from \"./modules/paymaster-guard-module/module.js\";\nexport { singleSignerValidationModuleAbi } from \"./modules/single-signer-validation/abis/singleSignerValidationModuleAbi.js\";\nexport { SingleSignerValidationModule } from \"./modules/single-signer-validation/module.js\";\nexport { timeRangeModuleAbi } from \"./modules/time-range-module/abis/timeRangeModuleAbi.js\";\nexport { TimeRangeModule } from \"./modules/time-range-module/module.js\";\nexport { webauthnValidationModuleAbi } from \"./modules/webauthn-validation/abis/webauthnValidationAbi.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ma-v2/index.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,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;AAQ/D,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,wBAAwB,EAAE,MAAM,mDAAmD,CAAC;AAE7F,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC3E,cAAc,8BAA8B,CAAC;AAE7C,OAAO,EACL,gCAAgC,EAChC,uCAAuC,EACvC,qCAAqC,EACrC,6CAA6C,EAC7C,gCAAgC,EAChC,yCAAyC,GAC1C,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAC1E,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;AAC1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC","sourcesContent":["// ma v2 exports\nexport { accountFactoryAbi } from \"./abis/accountFactoryAbi.js\";\nexport { modularAccountAbi } from \"./abis/modularAccountAbi.js\";\nexport { semiModularAccountBytecodeAbi } from \"./abis/semiModularAccountBytecodeAbi.js\";\nexport { semiModularAccountStorageAbi } from \"./abis/semiModularAccountStorageAbi.js\";\n\nexport { nativeSMASigner } from \"./account/nativeSMASigner.js\";\n\nexport type {\n ModuleEntity,\n ValidationConfig,\n HookConfig,\n ValidationData,\n} from \"./actions/common/types.js\";\nexport { HookType } from \"./actions/common/types.js\";\nexport {\n serializeValidationConfig,\n serializeHookConfig,\n serializeModuleEntity,\n} from \"./actions/common/utils.js\";\nexport type * from \"./actions/install-validation/installValidation.js\";\nexport { installValidationActions } from \"./actions/install-validation/installValidation.js\";\nexport type * from \"./actions/deferralActions.js\";\nexport { deferralActions } from \"./actions/deferralActions.js\";\nexport type * from \"./permissionBuilder.js\";\nexport { PermissionBuilder, PermissionType } from \"./permissionBuilder.js\";\nexport * from \"./permissionBuilderErrors.js\";\n\nexport {\n getDefaultAllowlistModuleAddress,\n getDefaultNativeTokenLimitModuleAddress,\n getDefaultPaymasterGuardModuleAddress,\n getDefaultSingleSignerValidationModuleAddress,\n getDefaultTimeRangeModuleAddress,\n getDefaultWebauthnValidationModuleAddress,\n} from \"./modules/utils.js\";\nexport { buildFullNonceKey, buildDeferredActionDigest } from \"./utils.js\";\nexport { allowlistModuleAbi } from \"./modules/allowlist-module/abis/allowlistModuleAbi.js\";\nexport { AllowlistModule } from \"./modules/allowlist-module/module.js\";\nexport { nativeTokenLimitModuleAbi } from \"./modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.js\";\nexport { NativeTokenLimitModule } from \"./modules/native-token-limit-module/module.js\";\nexport { paymasterGuardModuleAbi } from \"./modules/paymaster-guard-module/abis/paymasterGuardModuleAbi.js\";\nexport { PaymasterGuardModule } from \"./modules/paymaster-guard-module/module.js\";\nexport { singleSignerValidationModuleAbi } from \"./modules/single-signer-validation/abis/singleSignerValidationModuleAbi.js\";\nexport { SingleSignerValidationModule } from \"./modules/single-signer-validation/module.js\";\nexport { timeRangeModuleAbi } from \"./modules/time-range-module/abis/timeRangeModuleAbi.js\";\nexport { TimeRangeModule } from \"./modules/time-range-module/module.js\";\nexport { webauthnValidationModuleAbi } from \"./modules/webauthn-validation/abis/webauthnValidationAbi.js\";\nexport { WebAuthnValidationModule } from \"./modules/webauthn-validation/module.js\";\n"]}